From: Johannes Sixt Date: Fri, 23 Oct 2015 06:02:51 +0000 (+0200) Subject: read_branches_file: plug a FILE* leak X-Git-Tag: v2.7.0-rc0~68^2~1 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=0fb19906b5eb8fff9af59531aacd023920a24495;p=git-core%2Fgit.git read_branches_file: plug a FILE* leak The earlier rewrite f28e3ab2 (read_branches_file: simplify string handling) of read_branches_file() lost an fclose() call. Put it back. As on Windows files that are open cannot be removed, the leak manifests in a failure of 'git remote rename origin origin' when the remote's URL is specified in .git/branches/origin, because by the time that the command attempts to remove this file, it is still open. Signed-off-by: Johannes Sixt Acked-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/remote.c b/remote.c index 1101f82ea..fb161530c 100644 --- a/remote.c +++ b/remote.c @@ -282,6 +282,7 @@ static void read_branches_file(struct remote *remote) return; strbuf_getline(&buf, f, '\n'); + fclose(f); strbuf_trim(&buf); if (!buf.len) { strbuf_release(&buf);