diff options
author | Grzegorz Adam Hankiewicz <gradha@imap.cc> | 2014-03-29 12:29:17 +0100 |
---|---|---|
committer | Grzegorz Adam Hankiewicz <gradha@imap.cc> | 2014-03-29 12:29:17 +0100 |
commit | 20e55fc5d411dbe92e839fcaa8474ecb6e92e96a (patch) | |
tree | 9bec941c8b2676c14d135b95dd8640272cf600b3 | |
parent | a6f8bae69f36a582c0eb55988c1441421a3c042e (diff) | |
download | Nim-20e55fc5d411dbe92e839fcaa8474ecb6e92e96a.tar.gz |
Uses finally as statement to release zlib memory. Refs #1048.
-rw-r--r-- | lib/wrappers/zip/zlib.nim | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/wrappers/zip/zlib.nim b/lib/wrappers/zip/zlib.nim index 2d8ac9058..cb61783d2 100644 --- a/lib/wrappers/zip/zlib.nim +++ b/lib/wrappers/zip/zlib.nim @@ -231,6 +231,9 @@ proc uncompress*(sourceBuf: cstring, sourceLen: int): string = # Out of memory. return + # Make sure memory allocated by inflateInit2() is freed eventually. + finally: discard inflateEnd(z) + # Decompress all of self. while true: # Allow for concatenated gzip streams (per RFC 1952). @@ -281,8 +284,6 @@ proc uncompress*(sourceBuf: cstring, sourceLen: int): string = # Continue until all input consumed. if left == 0 and z.avail_in == 0: break - # Free the memory allocated by inflateInit2(). - discard inflateEnd(z) # Verify that the input is a valid gzip stream. if status != Z_STREAM_END: |