summaryrefslogtreecommitdiff
path: root/run-command.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-09-20 15:55:12 -0700
committerJunio C Hamano <gitster@pobox.com>2012-09-20 15:55:12 -0700
commitcc84144d48dc73271a119f8df5d5f680e53b4573 (patch)
tree3ac1514f8e3e611f6455f6ffe9a101a9ddcbef3d /run-command.c
parent96c2abea02ac36337eafcbd1cd1e208257b2dbf9 (diff)
parentbdee397d7c2345d467548ef9446a2a63b72c5449 (diff)
downloadgit-cc84144d48dc73271a119f8df5d5f680e53b4573.tar.gz
Merge branch 'dg/run-command-child-cleanup' into maint
* dg/run-command-child-cleanup: run-command.c: fix broken list iteration in clear_child_for_cleanup
Diffstat (limited to 'run-command.c')
-rw-r--r--run-command.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/run-command.c b/run-command.c
index f9922b9ecc..1101ef7237 100644
--- a/run-command.c
+++ b/run-command.c
@@ -53,13 +53,14 @@ static void mark_child_for_cleanup(pid_t pid)
static void clear_child_for_cleanup(pid_t pid)
{
- struct child_to_clean **last, *p;
+ struct child_to_clean **pp;
- last = &children_to_clean;
- for (p = children_to_clean; p; p = p->next) {
- if (p->pid == pid) {
- *last = p->next;
- free(p);
+ for (pp = &children_to_clean; *pp; pp = &(*pp)->next) {
+ struct child_to_clean *clean_me = *pp;
+
+ if (clean_me->pid == pid) {
+ *pp = clean_me->next;
+ free(clean_me);
return;
}
}