Commit 236e7579 by Ramsay Jones Committed by Shawn O. Pearce

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>
parent c94eb4aa
...@@ -310,9 +310,14 @@ static void set_stream_output(z_stream *s, void *out, size_t len) ...@@ -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) static int start_inflate(z_stream *s, gitfo_buf *obj, void *out, size_t len)
{ {
int status;
init_stream(s, out, len); init_stream(s, out, len);
set_stream_input(s, obj->data, obj->len); set_stream_input(s, obj->data, obj->len);
inflateInit(s);
if ((status = inflateInit(s)) < Z_OK)
return status;
return inflate(s, 0); return inflate(s, 0);
} }
...@@ -377,7 +382,8 @@ static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen) ...@@ -377,7 +382,8 @@ static int inflate_buffer(void *in, size_t inlen, void *out, size_t outlen)
init_stream(&zs, out, outlen); init_stream(&zs, out, outlen);
set_stream_input(&zs, in, inlen); set_stream_input(&zs, in, inlen);
inflateInit(&zs); if (inflateInit(&zs) < Z_OK)
return GIT_ERROR;
while (status == Z_OK) while (status == Z_OK)
status = inflate(&zs, Z_FINISH); status = inflate(&zs, Z_FINISH);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment