diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-11-09 04:08:24 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2013-11-09 04:08:24 +0900 |
| commit | 7aabc657f1c8ef7e8f433e5fc584c5592f8a16d4 (patch) | |
| tree | b4b865f29d4c3ed67230771c84e5598880331f8a /src/load.c | |
| parent | de790bdc2785ee36730563982afc45480f6c0f42 (diff) | |
| download | mruby-7aabc657f1c8ef7e8f433e5fc584c5592f8a16d4.tar.gz mruby-7aabc657f1c8ef7e8f433e5fc584c5592f8a16d4.zip | |
protect returning irep (in proc) from GC
Diffstat (limited to 'src/load.c')
| -rw-r--r-- | src/load.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/load.c b/src/load.c index 2b222b6c1..b6e2df47a 100644 --- a/src/load.c +++ b/src/load.c @@ -462,12 +462,15 @@ mrb_value mrb_load_irep(mrb_state *mrb, const uint8_t *bin) { mrb_irep *irep = mrb_read_irep(mrb, bin); + mrb_value val; if (!irep) { irep_error(mrb); return mrb_nil_value(); } - return mrb_context_run(mrb, mrb_proc_new(mrb, irep), mrb_top_self(mrb), 0); + val = mrb_context_run(mrb, mrb_proc_new(mrb, irep), mrb_top_self(mrb), 0); + mrb_irep_decref(mrb, irep); + return val; } #ifdef ENABLE_STDIO @@ -694,11 +697,14 @@ mrb_value mrb_load_irep_file(mrb_state *mrb, FILE* fp) { mrb_irep *irep = mrb_read_irep_file(mrb, fp); + mrb_value val; if (!irep) { irep_error(mrb); return mrb_nil_value(); } - return mrb_context_run(mrb, mrb_proc_new(mrb, irep), mrb_top_self(mrb), 0); + val = mrb_context_run(mrb, mrb_proc_new(mrb, irep), mrb_top_self(mrb), 0); + mrb_irep_decref(mrb, irep); + return val; } #endif /* ENABLE_STDIO */ |
