diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-01-06 19:59:50 +0200 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-01-06 21:23:26 +0200 |
commit | 5e2aca267883a03dae8193eda9328a48b187fe84 (patch) | |
tree | f3c20ca4f242c3acd672adbe20d010e3a2763853 /src/gunzip.c | |
parent | 6b2b9d303e61599d566a70b6e3100b9afe400d4b (diff) | |
download | apk-tools-5e2aca267883a03dae8193eda9328a48b187fe84.tar.gz apk-tools-5e2aca267883a03dae8193eda9328a48b187fe84.tar.bz2 apk-tools-5e2aca267883a03dae8193eda9328a48b187fe84.tar.xz apk-tools-5e2aca267883a03dae8193eda9328a48b187fe84.zip |
io: fix some memory leaks
Diffstat (limited to 'src/gunzip.c')
-rw-r--r-- | src/gunzip.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gunzip.c b/src/gunzip.c index 1d641ed..55c9e66 100644 --- a/src/gunzip.c +++ b/src/gunzip.c @@ -22,6 +22,7 @@ struct apk_gzip_istream { struct apk_bstream *bs; z_stream zs; int z_err; + int autoclose; }; static size_t gz_read(void *stream, void *ptr, size_t size) @@ -64,10 +65,12 @@ static void gz_close(void *stream) container_of(stream, struct apk_gzip_istream, is); inflateEnd(&gis->zs); + if (gis->autoclose) + gis->bs->close(gis->bs, NULL, NULL); free(gis); } -struct apk_istream *apk_bstream_gunzip(struct apk_bstream *bs) +struct apk_istream *apk_bstream_gunzip(struct apk_bstream *bs, int autoclose) { struct apk_gzip_istream *gis; @@ -83,6 +86,7 @@ struct apk_istream *apk_bstream_gunzip(struct apk_bstream *bs) .is.close = gz_close, .bs = bs, .z_err = 0, + .autoclose = autoclose, }; if (inflateInit2(&gis->zs, 15+32) != Z_OK) { |