summaryrefslogtreecommitdiffabout
path: root/src/prog.c
Side-by-side diff
Diffstat (limited to 'src/prog.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/prog.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/prog.c b/src/prog.c
index 83401ef..75b5228 100644
--- a/src/prog.c
+++ b/src/prog.c
@@ -386,3 +386,3 @@ env_get_locus(eval_environ_t env, struct mu_locus_range *locus)
locus->beg.mu_file = (char*)(env->dataseg + env->locus.file);
- env_register_auto(env, (void*) locus->beg.mu_file);
+ env_register_auto(env, (void*) &locus->beg.mu_file);
locus->beg.mu_line = env->locus.line;
@@ -495,2 +495,4 @@ env_register_auto(eval_environ_t env, void *ptr)
{
+ char *addr = *(char**)ptr;
+
if (env->numautos == MAX_AUTO_PTR)
@@ -498,2 +500,6 @@ env_register_auto(eval_environ_t env, void *ptr)
__FILE__, __LINE__);
+ /* Check if address is within the dataseg */
+ if (!(addr >= (char*) env->dataseg
+ && (addr < (char*) (env->dataseg + datasize + env->stack_size))))
+ ptr = NULL;
env->auto_ptr[env->numautos++] = ptr;
@@ -502,3 +508,3 @@ env_register_auto(eval_environ_t env, void *ptr)
/* Pop the last registered auto variable */
-void
+static void
env_pop_auto(eval_environ_t env)
@@ -508,3 +514,3 @@ env_pop_auto(eval_environ_t env)
-void
+static void
env_unregister_autos(eval_environ_t env)
@@ -514,3 +520,3 @@ env_unregister_autos(eval_environ_t env)
-void
+static void
env_fixup_autos(eval_environ_t env, ptrdiff_t offset)
@@ -520,3 +526,4 @@ env_fixup_autos(eval_environ_t env, ptrdiff_t offset)
STKVAL *pptr = env->auto_ptr[i];
- mf_c_val(*pptr,str) += offset; /*FIXME*/
+ if (pptr)
+ mf_c_val(*pptr,str) += offset; /*FIXME*/
}
@@ -801,3 +808,3 @@ heap_obstack_grow(eval_environ_t env, void * MFL_DATASEG ptr, size_t size)
- env_register_auto(env, ptr);
+ env_register_auto(env, (void*) &ptr);
if (env->tos - env->toh < words + B2STACK(env->temp_size))
@@ -831,3 +838,3 @@ pushs(eval_environ_t env, const char * MFL_DATASEG s)
- env_register_auto(env, (void*) s);
+ env_register_auto(env, (void*) &s);
off = heap_reserve(env, strlen(s) + 1);

Return to:

Send suggestions and report system problems to the System administrator.