{"thread":{"id":"51604","subject":"[PATCH] sha1-file: release strbuf after use","startedAt":"2019-08-07T11:15:34Z","lastAt":"2019-08-07T13:51:52Z","messageCount":3,"participants":["René Scharfe","Jeff King","Derrick Stolee"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"380066","messageId":"fa6ccb9f-11cd-7eec-fdbb-2de6a0bfcecf@web.de","threadId":"51604","inReplyTo":null,"subject":"[PATCH] sha1-file: release strbuf after use","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2019-08-07T11:15:25Z","receivedAt":"2019-08-07T11:15:34Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Signed-off-by: René Scharfe <l.s.r@web.de>\n---\nPatch generated with --function-context for easier review.\n\nThe plugged leak was added by a10a17877b (for_each_alternate_ref:\nreplace transport code with for-each-ref, 2017-02-08) and showed up in\n709dfa6990 (object-store.h: move for_each_alternate_ref() from\ntransport.h, 2019-07-01), where it caught my eye, belatedly.\n\n sha1-file.c | 1 +\n 1 file changed, 1 insertion(+)\n\ndiff --git a/sha1-file.c b/sha1-file.c\nindex 84fd02f107..487ea35d2d 100644\n--- a/sha1-file.c\n+++ b/sha1-file.c\n@@ -773,32 +773,33 @@ static void fill_alternate_refs_command(struct child_process *cmd,\n static void read_alternate_refs(const char *path,\n \t\t\t\talternate_ref_fn *cb,\n \t\t\t\tvoid *data)\n {\n \tstruct child_process cmd = CHILD_PROCESS_INIT;\n \tstruct strbuf line = STRBUF_INIT;\n \tFILE *fh;\n\n \tfill_alternate_refs_command(&cmd, path);\n\n \tif (start_command(&cmd))\n \t\treturn;\n\n \tfh = xfdopen(cmd.out, \"r\");\n \twhile (strbuf_getline_lf(&line, fh) != EOF) {\n \t\tstruct object_id oid;\n \t\tconst char *p;\n\n \t\tif (parse_oid_hex(line.buf, &oid, &p) || *p) {\n \t\t\twarning(_(\"invalid line while parsing alternate refs: %s\"),\n \t\t\t\tline.buf);\n \t\t\tbreak;\n \t\t}\n\n \t\tcb(&oid, data);\n \t}\n\n \tfclose(fh);\n \tfinish_command(&cmd);\n+\tstrbuf_release(&line);\n }\n\n struct alternate_refs_data {\n--\n2.22.0\n"},{"id":"380067","messageId":"20190807124859.GA5384@sigill.intra.peff.net","threadId":"51604","inReplyTo":"fa6ccb9f-11cd-7eec-fdbb-2de6a0bfcecf@web.de","subject":"Re: [PATCH] sha1-file: release strbuf after use","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-08-07T12:49:00Z","receivedAt":"2019-08-07T12:49:03Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Aug 07, 2019 at 01:15:25PM +0200, René Scharfe wrote:\n\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n> Patch generated with --function-context for easier review.\n> \n> The plugged leak was added by a10a17877b (for_each_alternate_ref:\n> replace transport code with for-each-ref, 2017-02-08) and showed up in\n> 709dfa6990 (object-store.h: move for_each_alternate_ref() from\n> transport.h, 2019-07-01), where it caught my eye, belatedly.\n\nThanks, the patch obviously looks good (though I wouldn't be sad for\nsome of your digging above to go into the commit message).\n\nI had a vague feeling that we had seen this particular leak before (and\npresumably the fix fell through the cracks). But I couldn't find it on\nthe list. I think after a while these strbuf_getline() leaks all start\nto look the same. :)\n\n-Peff\n"},{"id":"380074","messageId":"0d3c8de2-52e6-0e79-b2a0-056302847d43@gmail.com","threadId":"51604","inReplyTo":"fa6ccb9f-11cd-7eec-fdbb-2de6a0bfcecf@web.de","subject":"Re: [PATCH] sha1-file: release strbuf after use","fromName":"Derrick Stolee","fromEmail":"stolee@gmail.com","sentAt":"2019-08-07T13:51:47Z","receivedAt":"2019-08-07T13:51:52Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 8/7/2019 7:15 AM, René Scharfe wrote:\n> Signed-off-by: René Scharfe <l.s.r@web.de>\n> ---\n> Patch generated with --function-context for easier review.\n\nThanks again. LGTM.\n\n-Stolee\n"}]}