should not access scope after releasing memory pool

parent 155f3909
...@@ -87,12 +87,14 @@ static void codegen(codegen_scope *s, node *tree, int val); ...@@ -87,12 +87,14 @@ static void codegen(codegen_scope *s, node *tree, int val);
static void static void
codegen_error(codegen_scope *s, const char *message) codegen_error(codegen_scope *s, const char *message)
{ {
jmp_buf jmp;
if (!s) return; if (!s) return;
while (s->prev) { while (s->prev) {
codegen_scope *tmp = s->prev;
mrb_pool_close(s->mpool); mrb_pool_close(s->mpool);
s = s->prev; s = tmp;
} }
mrb_pool_close(s->mpool);
#ifdef ENABLE_STDIO #ifdef ENABLE_STDIO
if (s->filename && s->lineno) { if (s->filename && s->lineno) {
fprintf(stderr, "codegen error:%s:%d: %s\n", s->filename, s->lineno, message); fprintf(stderr, "codegen error:%s:%d: %s\n", s->filename, s->lineno, message);
...@@ -101,7 +103,9 @@ codegen_error(codegen_scope *s, const char *message) ...@@ -101,7 +103,9 @@ codegen_error(codegen_scope *s, const char *message)
fprintf(stderr, "codegen error: %s\n", message); fprintf(stderr, "codegen error: %s\n", message);
} }
#endif #endif
longjmp(s->jmp, 1); memcpy(&jmp, &s->jmp, sizeof(jmp_buf));
mrb_pool_close(s->mpool);
longjmp(jmp, 1);
} }
static void* static void*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment