aboutsummaryrefslogtreecommitdiffstats
path: root/commit.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2020-09-05 16:47:47 +0200
committerJunio C Hamano <gitster@pobox.com>2020-09-06 13:15:45 -0700
commit30035d9c66bc2a52352e3ad42b56047f06c20326 (patch)
tree72d735082b4dd68c78f6e363b86549b384cc29d8 /commit.c
parentThirteenth batch (diff)
downloadgit-30035d9c66bc2a52352e3ad42b56047f06c20326.tar.gz
git-30035d9c66bc2a52352e3ad42b56047f06c20326.zip
push: release strbufs used for refspec formatting
map_refspec() either returns the passed in ref string or a detached strbuf. This makes it hard for callers to release the possibly allocated memory, and set_refspecs() consequently leaks it. Let map_refspec() append any refspecs directly and release its own strbufs after use. Rename it to refspec_append_mapped() and don't return anything to reflect its increased responsibility. set_refspecs() also leaks its strbufs. Do the same here and directly call refspec_append() in each if branch instead of holding onto a detached strbuf, then dispose of the allocated memory after use. We need to add an else branch for the final call because all the other conditional branches already add their formatted refspec now. setup_push_upstream() and setup_push_current() forgot to release their strbufs as well; plug these leaks, too, while at it. None of these leaks were likely to impact users, because the number and sizes of refspecs are usually small and the allocations are only done once per program run. Clean them up nevertheless, as another step on the long road towards zero memory leaks. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'commit.c')
0 files changed, 0 insertions, 0 deletions