Skip to content

Commit 0fb1990

Browse files
j6tgitster
authored andcommitted
read_branches_file: plug a FILE* leak
The earlier rewrite f28e3ab (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 <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 34e02de commit 0fb1990

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

remote.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ static void read_branches_file(struct remote *remote)
282282
return;
283283

284284
strbuf_getline(&buf, f, '\n');
285+
fclose(f);
285286
strbuf_trim(&buf);
286287
if (!buf.len) {
287288
strbuf_release(&buf);

0 commit comments

Comments
 (0)