diff --git a/src/c/compiler.d b/src/c/compiler.d index eeef04798..20b11eb87 100644 --- a/src/c/compiler.d +++ b/src/c/compiler.d @@ -653,6 +653,7 @@ static void close_around_macros(cl_env_ptr env, cl_object mfun) { cl_object lex = mfun->bclosure.lex, record; + if(Null(lex)) return; cl_object *lex_vec = lex->vector.self.t; for (cl_index i = 0; i < lex->vector.dim; i++) { cl_object reg = lex_vec[i]; /* INV see interpreter.d for lexenv structure */ diff --git a/src/c/interpreter.d b/src/c/interpreter.d index 0aaec7b9d..3f099793d 100644 --- a/src/c/interpreter.d +++ b/src/c/interpreter.d @@ -130,12 +130,14 @@ VEclose_around_arg_type() static cl_object make_lex(cl_index n) { + if(!n) return ECL_NIL; return ecl_make_stack(n); } static void push_lex(cl_object stack, cl_object new) { + if(Null(stack)) ecl_miscompilation_error(); cl_index fillp = stack->vector.fillp; cl_index dim = stack->vector.dim; if (fillp == dim) { @@ -152,6 +154,7 @@ push_lex(cl_object stack, cl_object new) static void drop_lex(cl_object stack, cl_fixnum n) { + if(Null(stack)) ecl_miscompilation_error(); cl_index fillp = stack->vector.fillp; while (n--) stack->vector.self.t[--fillp] = ECL_NIL; stack->vector.fillp = fillp; @@ -160,12 +163,14 @@ drop_lex(cl_object stack, cl_fixnum n) static cl_object tangle_lex(cl_object stack) { + if(Null(stack)) return ECL_NIL; return ecl_make_fixnum(stack->vector.fillp); } static void unwind_lex(cl_object stack, cl_object where) { + if(Null(stack)) return; cl_fixnum nth = ecl_fixnum(where); drop_lex(stack, stack->vector.fillp - nth); } @@ -173,6 +178,7 @@ unwind_lex(cl_object stack, cl_object where) static cl_object ecl_lex_env_get_record(cl_object env, int s) { + if(Null(env)) ecl_miscompilation_error(); cl_index idx = (s<0) ? (env->vector.fillp+s) : s; return env->vector.self.t[idx]; }