builtin/help: fix dangling reference to `html_path`
commit02e36f9ffaf1f2395a19dc10c15423883c7b2817
authorPatrick Steinhardt <ps@pks.im>
Thu, 26 Sep 2024 11:46:00 +0000 (26 13:46 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Sep 2024 15:25:34 +0000 (27 08:25 -0700)
treef513bdfe0126c7d131882e3268c13bd7860c138c
parenta2b7f03e65ca8c0a5b6d1cbc42866db3df96aeed
builtin/help: fix dangling reference to `html_path`

In `get_html_page_path()` we may end up assigning the return value of
`system_path()` to the global `html_path` variable. But as we also
assign the returned value to `to_free`, we will deallocate its memory
upon returning from the function. Consequently, `html_path` will now
point to deallocated memory.

Fix this issue by instead assigning the value to a separate local
variable.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/help.c