Skip to content

Commit a38426e

Browse files
committed
sub-process: avoid leaking cmd
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent f4f85c7 commit a38426e

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

sub-process.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ void subprocess_stop(struct hashmap *hashmap, struct subprocess_entry *entry)
6363
finish_command(&entry->process);
6464

6565
hashmap_remove(hashmap, &entry->ent, NULL);
66+
FREE_AND_NULL(entry->cmd);
6667
}
6768

6869
static void subprocess_exit_handler(struct child_process *process)
@@ -150,6 +151,7 @@ int subprocess_start_strvec(struct hashmap *hashmap,
150151
err = start_command(process);
151152
if (err) {
152153
error("cannot fork to run subprocess '%s'", entry->cmd);
154+
FREE_AND_NULL(entry->cmd);
153155
return err;
154156
}
155157

@@ -158,6 +160,7 @@ int subprocess_start_strvec(struct hashmap *hashmap,
158160
err = startfn(entry);
159161
if (err) {
160162
error("initialization for subprocess '%s' failed", entry->cmd);
163+
FREE_AND_NULL(entry->cmd);
161164
subprocess_stop(hashmap, entry);
162165
return err;
163166
}

0 commit comments

Comments
 (0)