]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/push: fix leaking refspec query result
authorPatrick Steinhardt <ps@pks.im>
Thu, 5 Sep 2024 10:08:46 +0000 (12:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Sep 2024 15:49:10 +0000 (08:49 -0700)
commit7eb6f02c554b2e41f4b33152163868a84a0afa85
tree54d46c52f702b6f7a0ada477ced2aefbc5279aa5
parente03004f7f86a817af2b8d0752dfecac58e7d85e0
builtin/push: fix leaking refspec query result

When appending a refspec via `refspec_append_mapped()` we leak the
result of `query_refspecs()`. The overall logic around refspec queries
is quite weird, as callers are expected to either set the `src` or `dst`
pointers, and then the (allocated) result will be in the respective
other struct member.

As we have the `src` member set, plugging the memory leak is thus as
easy as just freeing the `dst` member. While at it, use designated
initializers to initialize the structure.

This leak was exposed by t5516, but fixing it is not sufficient to make
the whole test suite leak free.

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