@matheusbsbs / matheus-bagliano / commits / 0b1f113075
Fork 0

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 <jasampler@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Carlos Rica committed May 25, 2007 at 03:46 UTC 0b1f113075aafb0c91a406d984d0152e55c981da
1 file changed +1
object.c
+1
@@ -185,6 +185,7 @@ struct object *parse_object(const unsigned char *sha1)
185 if (buffer) {
186 struct object *obj;
187 if (check_sha1_signature(sha1, buffer, size, typename(type)) < 0) {
188 + free(buffer);
189 error("sha1 mismatch %s\n", sha1_to_hex(sha1));
190 return NULL;
191 }