Commit 4d0984b
fsck: do not reuse child_process structs
The run-command API makes no promises about what is left in a struct
child_process after a command finishes, and it's not safe to simply
reuse it again for a similar command. In particular:
- if you use child->args or child->env_array, they are cleared after
finish_command()
- likewise, start_command() may point child->argv at child->args->argv;
reusing that would lead to accessing freed memory
- the in/out/err may hold pipe descriptors from the previous run
These two calls are _probably_ OK because they do not use any of those
features. But it's only by chance, and may break in the future; let's
reinitialize our struct for each program we run.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>1 parent 8858448 commit 4d0984b
1 file changed
+6
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
841 | 841 | | |
842 | 842 | | |
843 | 843 | | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
844 | 847 | | |
845 | 848 | | |
846 | 849 | | |
| |||
859 | 862 | | |
860 | 863 | | |
861 | 864 | | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
862 | 868 | | |
863 | 869 | | |
864 | 870 | | |
| |||
0 commit comments