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 <j6t@kdbg.org> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Oct 23, 2015 at 08:02 UTC 0fb19906b5eb8fff9af59531aacd023920a24495
1 file changed +1
remote.c
+1
@@ -282,6 +282,7 @@ static void read_branches_file(struct remote *remote)
282 return;
283
284 strbuf_getline(&buf, f, '\n');
285 + fclose(f);
286 strbuf_trim(&buf);
287 if (!buf.len) {
288 strbuf_release(&buf);