{"thread":{"id":"8306","subject":"[PATCH] fix memory leak in parse_object when check_sha1_signature fails","startedAt":"2007-05-25T01:46:22Z","lastAt":"2007-05-25T02:38:46Z","messageCount":3,"participants":["Carlos Rica","Shawn O. Pearce","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43200","messageId":"1b46aba20705241846u615785eeh7c3ebeaf840b2180@mail.gmail.com","threadId":"8306","inReplyTo":null,"subject":"[PATCH] fix memory leak in parse_object when check_sha1_signature fails","fromName":"Carlos Rica","fromEmail":"jasampler@gmail.com","sentAt":"2007-05-25T01:46:22Z","receivedAt":"2007-05-25T01:46:22Z","isPatch":true,"sender":{"key":"jasampler@gmail.com","avatar":null},"body":"When check_sha1_signature fails, program is not terminated:\nit prints an error message and returns NULL, so the\nbuffer returned by read_sha1_file should be freed before.\n\nSigned-off-by: Carlos Rica <jasampler@gmail.com>\n---\n object.c |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/object.c b/object.c\nindex 78a44a6..ccd7dd7 100644\n--- a/object.c\n+++ b/object.c\n@@ -185,6 +185,7 @@ struct object *parse_object(const unsigned char *sha1)\n \tif (buffer) {\n \t\tstruct object *obj;\n \t\tif (check_sha1_signature(sha1, buffer, size, typename(type)) < 0) {\n+\t\t\tfree(buffer);\n \t\t\terror(\"sha1 mismatch %s\\n\", sha1_to_hex(sha1));\n \t\t\treturn NULL;\n \t\t}\n-- \n1.5.0\n"},{"id":"43207","messageId":"20070525020939.GT28023@spearce.org","threadId":"8306","inReplyTo":"1b46aba20705241846u615785eeh7c3ebeaf840b2180@mail.gmail.com","subject":"Re: [PATCH] fix memory leak in parse_object when check_sha1_signature fails","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-05-25T02:09:39Z","receivedAt":"2007-05-25T02:09:39Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Carlos Rica <jasampler@gmail.com> wrote:\n> When check_sha1_signature fails, program is not terminated:\n> it prints an error message and returns NULL, so the\n> buffer returned by read_sha1_file should be freed before.\n...\n> \t\tif (check_sha1_signature(sha1, buffer, size, typename(type)) \n> \t\t< 0) {\n...\n\ngmail strikes again.  The above line is wrapped, which means your\npatch is whitespace damaged and won't apply properly.\n\n-- \nShawn.\n"},{"id":"43214","messageId":"7virahtyo9.fsf@assigned-by-dhcp.cox.net","threadId":"8306","inReplyTo":"20070525020939.GT28023@spearce.org","subject":"Re: [PATCH] fix memory leak in parse_object when check_sha1_signature fails","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-05-25T02:38:46Z","receivedAt":"2007-05-25T02:38:46Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Shawn O. Pearce\" <spearce@spearce.org> writes:\n\n> Carlos Rica <jasampler@gmail.com> wrote:\n>> When check_sha1_signature fails, program is not terminated:\n>> it prints an error message and returns NULL, so the\n>> buffer returned by read_sha1_file should be freed before.\n> ...\n>> \t\tif (check_sha1_signature(sha1, buffer, size, typename(type)) \n>> \t\t< 0) {\n> ...\n>\n> gmail strikes again.  The above line is wrapped, which means your\n> patch is whitespace damaged and won't apply properly.\n\nThat is only between your eyes, imagination and your MUA (hint:\n\"format: flowed\").\n\nFor applying after saving it in mbox it does not pose a problem,\nbut it _does_ affect people who want to comment on the patch\nwhile in MUA.\n\nIs there a way to turn that \"format: flawed\" off?\n"}]}