Permalink
Browse files

- fix mrbc_filename leak; cxt->filename would not be freed until the …

…state is closed.
  • Loading branch information...
nozomiS committed Sep 4, 2016
1 parent 22dc84f commit 068b46d5e2d3c17db9f48b94f217bf9237ed92bc
Showing with 5 additions and 1 deletion.
  1. +5 −1 mrbgems/mruby-compiler/core/parse.y
@@ -5540,6 +5540,7 @@ mrbc_context_new(mrb_state *mrb)
MRB_API void
mrbc_context_free(mrb_state *mrb, mrbc_context *cxt)
{
mrb_free(mrb, cxt->filename);
mrb_free(mrb, cxt->syms);
mrb_free(mrb, cxt);
}
@@ -5549,9 +5550,12 @@ mrbc_filename(mrb_state *mrb, mrbc_context *c, const char *s)
{
if (s) {
int len = strlen(s);
char *p = (char *)mrb_alloca(mrb, len + 1);
char *p = (char *)mrb_malloc(mrb, len + 1);
memcpy(p, s, len + 1);
if (c->filename) {
mrb_free(mrb, c->filename);
}
c->filename = p;
}
return c->filename;

0 comments on commit 068b46d

Please sign in to comment.