http-backend.c: fix cmd_main() memory leak, refactor reg{exec,free}()
commit2139bd0200b2ee51674d8778cd26a9f38220a5b7
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 6 Feb 2023 23:07:45 +0000 (7 00:07 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Feb 2023 23:34:38 +0000 (6 15:34 -0800)
tree61548395890da8417c6779ab32c80e2f1c0b14de
parenteef75d247a5f1ce07cb21fa05196cdf7bc443e13
http-backend.c: fix cmd_main() memory leak, refactor reg{exec,free}()

Fix a memory leak that's been with us ever since
2f4038ab337 (Git-aware CGI to provide dumb HTTP transport,
2009-10-30). In this case we're not calling regerror() after a failed
regexec(), and don't otherwise use "re" afterwards.

We can therefore simplify this code by calling regfree() right after
the regexec(). An alternative fix would be to add a regfree() to both
the "return" and "break" path in this for-loop.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
http-backend.c