diff options
| author | Ramsay Jones <ramsay@ramsay1.demon.co.uk> | 2009-02-03 18:23:50 +0000 |
|---|---|---|
| committer | Shawn O. Pearce <spearce@spearce.org> | 2009-02-11 10:46:29 -0800 |
| commit | 236e7579fed7763be77209efb8708960982f3cb3 (patch) | |
| tree | 7b2a0b6f0d56e59dacf05a30087b58c1ff93cad6 /src/odb.c | |
| parent | c94eb4aa7665d04c8412a72f3554401d2e89e03c (diff) | |
| download | libgit2-236e7579fed7763be77209efb8708960982f3cb3.tar.gz | |
Check for error returns from inflateInit()
At present, it is sufficient to ensure that an error return
from inflateInit() is not ignored. Most error returns, like
Z_VERSION_ERROR and Z_STREAM_ERROR, indicate programming or
build errors. These errors could, perhaps, be handled with
simple asserts. However, for a Z_MEM_ERROR, we may want to
perform some further error handling in the future.
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 | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -310,9 +310,14 @@ static void set_stream_output(z_stream *s, void *out, size_t len) static int start_inflate(z_stream *s, gitfo_buf *obj, void *out, size_t len) { + int status; + init_stream(s, out, len); set_stream_input(s, obj->data, obj->len); - inflateInit(s); + + if ((status = inflateInit(s)) < Z_OK) + return status; + return inflate(s, 0); } @@ -377,7 +382,8 @@ static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen) init_stream(&zs, out, outlen); set_stream_input(&zs, in, inlen); - inflateInit(&zs); + if (inflateInit(&zs) < Z_OK) + return GIT_ERROR; while (status == Z_OK) status = inflate(&zs, Z_FINISH); |
