diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-01-06 17:49:49 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-01-07 11:14:26 +0100 |
commit | 85aa507f737b99501bb91cf79985af78f46ff0be (patch) | |
tree | b4423a72ea15412e534cdca83fe91ffaba09bd4d /tools | |
parent | be343661b076f3f57e7eb9ca1a5a4d3529752b58 (diff) |
Avoid memory leaks upon (de)compression failure
This e.g. reduces the LSan-reported leakage during CppunitTest_sd_filters_test
from
SUMMARY: AddressSanitizer: 504104 byte(s) leaked in 4654 allocation(s).
to
SUMMARY: AddressSanitizer: 115048 byte(s) leaked in 4639 allocation(s).
Change-Id: If922e872d9f696847face198e082144ccd5f12de
Diffstat (limited to 'tools')
-rw-r--r-- | tools/source/zcodec/zcodec.cxx | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/source/zcodec/zcodec.cxx b/tools/source/zcodec/zcodec.cxx index 7a983aaf9392..f11f7898ef15 100644 --- a/tools/source/zcodec/zcodec.cxx +++ b/tools/source/zcodec/zcodec.cxx @@ -82,17 +82,20 @@ long ZCodec::EndCompression() { long retvalue = 0; - if (mbStatus && meState != STATE_INIT) + if (meState != STATE_INIT) { if (meState == STATE_COMPRESS) { - do + if (mbStatus) { + do + { + ImplWriteBack(); + } + while ( deflate( PZSTREAM, Z_FINISH ) != Z_STREAM_END ); + ImplWriteBack(); } - while ( deflate( PZSTREAM, Z_FINISH ) != Z_STREAM_END ); - - ImplWriteBack(); retvalue = PZSTREAM->total_in; deflateEnd( PZSTREAM ); |