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
This commit is contained in:
Stephan Bergmann
2016-01-06 17:49:49 +01:00
parent be343661b0
commit 85aa507f73

View File

@@ -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 );