From: Carlos Rica Date: Fri, 25 May 2007 01:46:22 +0000 (+0200) Subject: fix memory leak in parse_object when check_sha1_signature fails X-Git-Tag: v1.5.2.1~16^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=0b1f113075aafb0c91a406d984d0152e55c981da;p=git.git fix memory leak in parse_object when check_sha1_signature fails When check_sha1_signature fails, program is not terminated: it prints an error message and returns NULL, so the buffer returned by read_sha1_file should be freed before. Signed-off-by: Carlos Rica Signed-off-by: Junio C Hamano --- diff --git a/object.c b/object.c index 78a44a6ef..ccd7dd796 100644 --- a/object.c +++ b/object.c @@ -185,6 +185,7 @@ struct object *parse_object(const unsigned char *sha1) if (buffer) { struct object *obj; if (check_sha1_signature(sha1, buffer, size, typename(type)) < 0) { + free(buffer); error("sha1 mismatch %s\n", sha1_to_hex(sha1)); return NULL; }