Skip to content

Commit

Permalink
Null check for irep & initialize loc.lineno
Browse files Browse the repository at this point in the history
  • Loading branch information
jbreeden committed Mar 5, 2016
1 parent 4f4fa0a commit e02ff85
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/backtrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ each_backtrace(mrb_state *mrb, mrb_int ciidx, mrb_code *pc0, each_backtrace_func

for (i = ciidx; i >= 0; i--) {
struct backtrace_location_raw loc;
loc.lineno = -1;

mrb_callinfo *ci;
mrb_irep *irep;
mrb_code *pc;
Expand All @@ -128,8 +130,11 @@ each_backtrace(mrb_state *mrb, mrb_int ciidx, mrb_code *pc0, each_backtrace_func
else {
pc = pc0;
}
loc.filename = mrb_debug_get_filename(irep, (uint32_t)(pc - irep->iseq));
loc.lineno = mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq));

if (irep) {
loc.filename = mrb_debug_get_filename(irep, (uint32_t)(pc - irep->iseq));
loc.lineno = mrb_debug_get_line(irep, (uint32_t)(pc - irep->iseq));
}

if (loc.lineno == -1) continue;

Expand Down

0 comments on commit e02ff85

Please sign in to comment.