Skip to content

Commit d90dafb

Browse files
avargitster
authored andcommitted
cat-file: fix a memory leak in --batch-command mode
Fix a memory leak introduced in 440c705 (cat-file: add --batch-command mode, 2022-02-18). The free_cmds() function was only called on "queued_nr" if we had a "flush" command. As the "without flush for blob info" test added in the same commit shows we can't rely on that, so let's call free_cmds() again at the end. Since "nr" follows the usual pattern of being set to 0 if we've free()'d the memory already it's OK to call it twice, even in cases where we are doing a "flush". Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fd74ac9 commit d90dafb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

builtin/cat-file.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ static void batch_objects_command(struct batch_options *opt,
655655
free_cmds(queued_cmd, &nr);
656656
}
657657

658+
free_cmds(queued_cmd, &nr);
658659
free(queued_cmd);
659660
strbuf_release(&input);
660661
}

0 commit comments

Comments
 (0)