diff options
| author | Ramsay Jones <ramsay@ramsay1.demon.co.uk> | 2009-02-03 18:22:09 +0000 |
|---|---|---|
| committer | Shawn O. Pearce <spearce@spearce.org> | 2009-02-11 10:45:50 -0800 |
| commit | c94eb4aa7665d04c8412a72f3554401d2e89e03c (patch) | |
| tree | c7417a02d56346deb435359fdba3de19c0be2f62 /src/odb.c | |
| parent | 357bf823711de56d93f51d9f4618ec2068d2244f (diff) | |
| download | libgit2-c94eb4aa7665d04c8412a72f3554401d2e89e03c.tar.gz | |
Fix a potential memory leak
In particular, neglecting to call inflateEnd() along various
codepaths in the inflate_tail() routine, would result in the
failure to release zlib internal state.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'src/odb.c')
| -rw-r--r-- | src/odb.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -341,8 +341,10 @@ static void *inflate_tail(z_stream *s, void *hb, size_t used, obj_hdr *hdr) * initial sequence of inflated data from the tail of the * head buffer, if any. */ - if ((buf = git__malloc(hdr->size + 1)) == NULL) + if ((buf = git__malloc(hdr->size + 1)) == NULL) { + inflateEnd(s); return NULL; + } tail = s->total_out - used; if (used > 0 && tail > 0) { if (tail > hdr->size) @@ -354,7 +356,9 @@ static void *inflate_tail(z_stream *s, void *hb, size_t used, obj_hdr *hdr) /* * inflate the remainder of the object data, if any */ - if (hdr->size >= used) { + if (hdr->size < used) + inflateEnd(s); + else { set_stream_output(s, buf + used, hdr->size - used); if (finish_inflate(s)) { free(buf); |
