]> git.ipfire.org Git - thirdparty/git.git/commitdiff
builtin/receive-pack: properly init receive_hook strbuf
authorAdrian Ratiu <adrian.ratiu@collabora.com>
Wed, 25 Mar 2026 19:54:53 +0000 (21:54 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 25 Mar 2026 21:00:45 +0000 (14:00 -0700)
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>
builtin/receive-pack.c

index 415bb57362c4aeee93053ec7c4e5d5ff52b77de2..63b2f7d54336402ae627b7de85b8634f6b0d8ce5 100644 (file)
@@ -963,6 +963,7 @@ static int run_receive_hook(struct command *commands,
        /* set up stdin callback */
        feed_init_state.cmd = commands;
        feed_init_state.skip_broken = skip_broken;
+       strbuf_init(&feed_init_state.buf, 0);
        opt.feed_pipe_ctx = &feed_init_state;
        opt.feed_pipe = feed_receive_hook_cb;
        opt.feed_pipe_cb_data_alloc = receive_hook_feed_state_alloc;