Skip to content

Commit 67c74d6

Browse files
authored
Merge pull request #159 from pmhahn/sigsegv
trace: fix SIGSEGV after pop
2 parents ae04b5f + a86f3c0 commit 67c74d6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/remake.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ update_file_1 (struct file *file, unsigned int depth,
456456
}
457457

458458
DBF (DB_VERBOSE, _("File '%s' was considered already.\n"));
459+
p_stack_top = p_stack_top->p_parent;
459460
trace_pop_target(p_call_stack);
460461
return 0;
461462
}
@@ -467,10 +468,12 @@ update_file_1 (struct file *file, unsigned int depth,
467468
break;
468469
case cs_running:
469470
DBF (DB_VERBOSE, _("Still updating file '%s'.\n"));
471+
p_stack_top = p_stack_top->p_parent;
470472
trace_pop_target(p_call_stack);
471473
return 0;
472474
case cs_finished:
473475
DBF (DB_VERBOSE, _("Finished updating file '%s'.\n"));
476+
p_stack_top = p_stack_top->p_parent;
474477
trace_pop_target(p_call_stack);
475478
return file->update_status;
476479
default:
@@ -707,6 +710,7 @@ update_file_1 (struct file *file, unsigned int depth,
707710
set_command_state (file, cs_deps_running);
708711
--depth;
709712
DBF (DB_VERBOSE, _("The prerequisites of '%s' are being made.\n"));
713+
p_stack_top = p_stack_top->p_parent;
710714
trace_pop_target(p_call_stack);
711715
return 0;
712716
}
@@ -728,6 +732,7 @@ update_file_1 (struct file *file, unsigned int depth,
728732
OS (error, NILF,
729733
_("Target '%s' not remade because of errors."), file->name);
730734

735+
p_stack_top = p_stack_top->p_parent;
731736
trace_pop_target(p_call_stack);
732737
return dep_status;
733738
}
@@ -838,6 +843,7 @@ update_file_1 (struct file *file, unsigned int depth,
838843
}
839844

840845
notice_finished_file (file);
846+
p_stack_top = p_stack_top->p_parent;
841847
trace_pop_target(p_call_stack);
842848

843849
/* Since we don't need to remake the file, convert it to use the
@@ -871,6 +877,7 @@ update_file_1 (struct file *file, unsigned int depth,
871877
DBF (DB_VERBOSE, _("Recipe of '%s' is being run.\n"));
872878
if ( file->tracing & BRK_AFTER_CMD || i_debugger_stepping )
873879
enter_debugger(p_call_stack, file, 0, DEBUG_BRKPT_AFTER_CMD);
880+
p_stack_top = p_stack_top->p_parent;
874881
trace_pop_target(p_call_stack);
875882
return 0;
876883
}
@@ -894,6 +901,7 @@ update_file_1 (struct file *file, unsigned int depth,
894901
if ( file->tracing & BRK_AFTER_CMD || i_debugger_stepping )
895902
enter_debugger(p_call_stack, file, 0, DEBUG_BRKPT_AFTER_CMD);
896903

904+
p_stack_top = p_stack_top->p_parent;
897905
trace_pop_target(p_call_stack);
898906
return file->update_status;
899907
}

src/trace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ trace_pop_target (target_stack_node_t *p)
9191
}
9292

9393
free(p->p_target);
94+
p->p_target = NULL;
9495
free(p);
9596
}
9697

0 commit comments

Comments
 (0)