aboutsummaryrefslogtreecommitdiff
path: root/lib/gunzip.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2014-12-02 13:17:39 -0700
committerTom Rini <trini@ti.com>2015-01-14 11:35:44 -0500
commit9c55c54fb474ba5bc005e489639aa06c3c00d012 (patch)
treea8f70a715afa7efb79668fc926ae8df026ab28a7 /lib/gunzip.c
parent362a0e43a37aa5a6316bcf895def4eda8391bb2e (diff)
downloadu-boot-9c55c54fb474ba5bc005e489639aa06c3c00d012.zip
u-boot-9c55c54fb474ba5bc005e489639aa06c3c00d012.tar.gz
u-boot-9c55c54fb474ba5bc005e489639aa06c3c00d012.tar.bz2
gunzip: Update lenp even on error
This allows the caller to easily detect how much of the destination buffer has been used. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/gunzip.c')
-rw-r--r--lib/gunzip.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/gunzip.c b/lib/gunzip.c
index 35abfb38..f469fcb 100644
--- a/lib/gunzip.c
+++ b/lib/gunzip.c
@@ -73,6 +73,7 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
int stoponerr, int offset)
{
z_stream s;
+ int err = 0;
int r;
s.zalloc = gzalloc;
@@ -92,13 +93,13 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
if (stoponerr == 1 && r != Z_STREAM_END &&
(s.avail_out == 0 || r != Z_BUF_ERROR)) {
printf("Error: inflate() returned %d\n", r);
- inflateEnd(&s);
- return -1;
+ err = -1;
+ break;
}
s.avail_in = *lenp - offset - (int)(s.next_out - (unsigned char*)dst);
} while (r == Z_BUF_ERROR);
*lenp = s.next_out - (unsigned char *) dst;
inflateEnd(&s);
- return 0;
+ return err;
}