Skip to content

Commit e3d2364

Browse files
peffgitster
authored andcommitted
imap-send: free all_msgs strbuf in "out" label
We read stdin into a strbuf, but most code paths never release it, causing a leak (albeit a minor one, as we leak only when exiting from the main function of the program). Commit 56f4f4a (imap-send: minimum leakfix, 2024-06-04) did the minimum to plug the one instance we see in the test suite, when we read an empty input. But it was sufficient only because aside from this noop invocation, we don't test imap-send at all! The right spot to free is in the "out" label, which is hit by all code paths before leaving the function. We couldn't do that in 56f4f4a because there was no unified exit path. That came separately in 3aca5f7 (imap-send: fix leaking memory in `imap_server_conf`, 2024-06-04), which cleaned up many other leaks (but not this one). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f5598fc commit e3d2364

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

imap-send.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,6 @@ int cmd_main(int argc, const char **argv)
15551555
}
15561556

15571557
if (all_msgs.len == 0) {
1558-
strbuf_release(&all_msgs);
15591558
fprintf(stderr, "nothing to send\n");
15601559
ret = 1;
15611560
goto out;
@@ -1586,5 +1585,6 @@ int cmd_main(int argc, const char **argv)
15861585
free(server.user);
15871586
free(server.pass);
15881587
free(server.auth_method);
1588+
strbuf_release(&all_msgs);
15891589
return ret;
15901590
}

0 commit comments

Comments
 (0)