Skip to content

Commit

Permalink
[PATCH] Plug memory leaks in git-unpack-objects
Browse files Browse the repository at this point in the history
- Call inflateEnd to release zlib state after use.
- After resolving delta, free base object data.

Signed-off-by: Sergey Vlasov <vsu@altlinux.ru>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Sergey Vlasov authored and Junio C Hamano committed Aug 3, 2005
1 parent 40b64d4 commit ee63914
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion unpack-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static void *get_data(unsigned long size)
stream.next_in = fill(1);
stream.avail_in = len;
}
inflateEnd(&stream);
return buf;
}

Expand Down Expand Up @@ -167,6 +168,7 @@ static int unpack_delta_entry(unsigned long delta_size)
unsigned long base_size;
char type[20];
unsigned char base_sha1[20];
int result;

memcpy(base_sha1, fill(20), 20);
use(20);
Expand All @@ -184,7 +186,9 @@ static int unpack_delta_entry(unsigned long delta_size)
base = read_sha1_file(base_sha1, type, &base_size);
if (!base)
die("failed to read delta-pack base object %s", sha1_to_hex(base_sha1));
return resolve_delta(type, base, base_size, delta_data, delta_size);
result = resolve_delta(type, base, base_size, delta_data, delta_size);
free(base);
return result;
}

static void unpack_one(unsigned nr, unsigned total)
Expand Down

0 comments on commit ee63914

Please sign in to comment.