# Re: \[PATCH v2\] pager: fix crash when pager program doesn't exist

- From: Enzo Matsumiya \<hidden\>
- Date: 2021-11-22 15:31:25 
- List: git
- Page: https://ratatoskr.run/git/2021/11/7912827
- Thread: https://ratatoskr.run/git/2021/11/7912765/t.md

```text
On 11/21, Junio C Hamano wrote:
>It is rather common for us to reuse "struct child_process" in a code
>path, e.g. builtin/worktree.c::add_worktree() prepares a single
>instance of such a struct, sets cp.git_cmd to true, and runs either
>"update-ref" or "symbolic-ref" to update "HEAD".  After successful
>invocation of such a git subcommand, it then runs "git reset --hard",
>with this piece of code:

Do you agree that at least NULLing .argv and .env could be part of
child_process_clear()?

diff --git a/run-command.c b/run-command.c
index a7bf81025afb..3839a26eff11 100644
--- a/run-command.c
+++ b/run-command.c
@@ -18,8 +18,9 @@ void child_process_init(struct child_process *child)
 void child_process_clear(struct child_process *child)
 {
        strvec_clear(&child->args);
+       child->argv = NULL;
        strvec_clear(&child->env_array);
+       child->env = NULL;
 }

With this change on main, all tests are successful.


Cheers,

Enzo
```
