]> Kevux Git Server - rit/commit
stash: do not pass strbuf by value
authorDeveshi Dwivedi <deveshigurgaon@gmail.com>
Sun, 15 Mar 2026 09:44:44 +0000 (09:44 +0000)
committerJunio C Hamano <gitster@pobox.com>
Sun, 15 Mar 2026 21:46:51 +0000 (14:46 -0700)
commit8f8e1b080701d4b02ca3732eed2706b1a5328c5d
tree3799e1f859d4212dc0f4c2eb1689dd857d3382d0
parent65fec23b577d09122865d239ce454d7946691c2a
stash: do not pass strbuf by value

save_untracked_files() takes its 'files' parameter as struct strbuf
by value.  Passing a strbuf by value copies the struct but shares
the underlying buffer between caller and callee, risking a dangling
pointer and double-free if the callee reallocates.

The function needs both the buffer and its length for
pipe_command(), so a plain const char * is not sufficient here.
Switch the parameter to struct strbuf * and update the caller to
pass a pointer.

Signed-off-by: Deveshi Dwivedi <deveshigurgaon@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/stash.c