Skip to content

Commit 6b9f9e2

Browse files
10ne1gitster
authored andcommitted
builtin/receive-pack: properly init receive_hook strbuf
The run_receive_hook() stack-allocated `struct receive_hook_feed_state` is a template with initial values for child states allocated on the heap for each hook process, by calling receive_hook_feed_state_alloc() when spinning up each hook child. All these values are already initialized to zero, however I forgot to properly initialize the strbuf, which I left NULL. This is more of a code cleanup because in practice it has no effect, the states used by the children are always initialized, however it's good to fix in case someone ends up accidentally dereferencing the NULL pointer in the future. Reported-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent add3564 commit 6b9f9e2

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

builtin/receive-pack.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,7 @@ static int run_receive_hook(struct command *commands,
963963
/* set up stdin callback */
964964
feed_init_state.cmd = commands;
965965
feed_init_state.skip_broken = skip_broken;
966+
strbuf_init(&feed_init_state.buf, 0);
966967
opt.feed_pipe_ctx = &feed_init_state;
967968
opt.feed_pipe = feed_receive_hook_cb;
968969
opt.feed_pipe_cb_data_alloc = receive_hook_feed_state_alloc;

0 commit comments

Comments
 (0)