Uses finally as statement to release zlib memory. Refs #1048.
This commit is contained in:
parent
a6f8bae69f
commit
20e55fc5d4
1 changed files with 3 additions and 2 deletions
|
|
@ -231,6 +231,9 @@ proc uncompress*(sourceBuf: cstring, sourceLen: int): string =
|
||||||
# Out of memory.
|
# Out of memory.
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Make sure memory allocated by inflateInit2() is freed eventually.
|
||||||
|
finally: discard inflateEnd(z)
|
||||||
|
|
||||||
# Decompress all of self.
|
# Decompress all of self.
|
||||||
while true:
|
while true:
|
||||||
# Allow for concatenated gzip streams (per RFC 1952).
|
# Allow for concatenated gzip streams (per RFC 1952).
|
||||||
|
|
@ -281,8 +284,6 @@ proc uncompress*(sourceBuf: cstring, sourceLen: int): string =
|
||||||
# Continue until all input consumed.
|
# Continue until all input consumed.
|
||||||
if left == 0 and z.avail_in == 0:
|
if left == 0 and z.avail_in == 0:
|
||||||
break
|
break
|
||||||
# Free the memory allocated by inflateInit2().
|
|
||||||
discard inflateEnd(z)
|
|
||||||
|
|
||||||
# Verify that the input is a valid gzip stream.
|
# Verify that the input is a valid gzip stream.
|
||||||
if status != Z_STREAM_END:
|
if status != Z_STREAM_END:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue