Skip to content

Commit

Permalink
fix memory leak in parse_object when check_sha1_signature fails
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Carlos Rica authored and Junio C Hamano committed May 25, 2007
1 parent c075aea commit 0b1f113
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0b1f113

Please sign in to comment.