backtrace.c: pedantic check for empty backtrace; ref #5394

parent 85808e50
...@@ -197,6 +197,7 @@ mrb_unpack_backtrace(mrb_state *mrb, mrb_value backtrace) ...@@ -197,6 +197,7 @@ mrb_unpack_backtrace(mrb_state *mrb, mrb_value backtrace)
bt = (struct backtrace_location*)mrb_data_check_get_ptr(mrb, backtrace, &bt_type); bt = (struct backtrace_location*)mrb_data_check_get_ptr(mrb, backtrace, &bt_type);
if (bt == NULL) goto empty_backtrace; if (bt == NULL) goto empty_backtrace;
n = (mrb_int)RDATA(backtrace)->flags; n = (mrb_int)RDATA(backtrace)->flags;
if (n == 0) goto empty_backtrace;
backtrace = mrb_ary_new_capa(mrb, n); backtrace = mrb_ary_new_capa(mrb, n);
ai = mrb_gc_arena_save(mrb); ai = mrb_gc_arena_save(mrb);
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
......
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