From 2871d0cdc5e5ef952d27187b5488888bbd18c5b0 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Mon, 1 Apr 2019 14:13:06 +0900 Subject: Avoid keeping pointers from `mrb_sym2name_len()`; fix #4342 The addresses for packed inline symbols reference `mrb->symbuf` that could be overridden by the later call of `mrb_sym2name_len`. Since file names in call stack information are kept as symbols, keeping the address in the C structures could cause problems like #4342. This changes small incompatible changes in function prototypes: * `mrb_parser_get_filename`: return value changed to `mrb_sym`. * `mrb_debug_get_filename`: add `mrb_state*` as a first argument. * `mrb_debug_get_line`: ditto. I believe above functions are almost internal, and no third-party mrbgem use them. --- mrbgems/mruby-proc-ext/src/proc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mrbgems/mruby-proc-ext') diff --git a/mrbgems/mruby-proc-ext/src/proc.c b/mrbgems/mruby-proc-ext/src/proc.c index 4b85c245d..17884e3c6 100644 --- a/mrbgems/mruby-proc-ext/src/proc.c +++ b/mrbgems/mruby-proc-ext/src/proc.c @@ -25,8 +25,8 @@ mrb_proc_source_location(mrb_state *mrb, mrb_value self) int32_t line; const char *filename; - filename = mrb_debug_get_filename(irep, 0); - line = mrb_debug_get_line(irep, 0); + filename = mrb_debug_get_filename(mrb, irep, 0); + line = mrb_debug_get_line(mrb, irep, 0); return (!filename && line == -1)? mrb_nil_value() : mrb_assoc_new(mrb, mrb_str_new_cstr(mrb, filename), mrb_fixnum_value(line)); @@ -46,11 +46,11 @@ mrb_proc_inspect(mrb_state *mrb, mrb_value self) int32_t line; mrb_str_cat_lit(mrb, str, "@"); - filename = mrb_debug_get_filename(irep, 0); + filename = mrb_debug_get_filename(mrb, irep, 0); mrb_str_cat_cstr(mrb, str, filename ? filename : "-"); mrb_str_cat_lit(mrb, str, ":"); - line = mrb_debug_get_line(irep, 0); + line = mrb_debug_get_line(mrb, irep, 0); if (line != -1) { str = mrb_format(mrb, "%S:%S", str, mrb_fixnum_value(line)); } -- cgit v1.2.3