]> git.ipfire.org Git - thirdparty/git.git/commit - wt-status.c
split_commit_in_progress(): simplify & fix memory leak
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Thu, 4 May 2017 13:56:44 +0000 (15:56 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 8 May 2017 03:18:19 +0000 (12:18 +0900)
commit41fc6b33fc0cef748f84906810bb36fcd491f0a1
treee44e72a867dbc534bbc3b079228e545e415d1f56
parent514e8039444565f7806e065579090167db5e489c
split_commit_in_progress(): simplify & fix memory leak

This function did a whole lot of unnecessary work, such as reading in
four files just to figure out that, oh, hey, we do not need to look at
them after all because the HEAD is not detached.

Simplify the entire function to return early when possible, to read in
the files only when necessary, and to release the allocated memory
always (there was a leak, reported via Coverity, where we failed to
release the allocated strings if the HEAD is not detached).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
wt-status.c