2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-06-05 03:40:53 +00:00

Fix Pl_Flate memory leak on error (fixes #148)

This commit is contained in:
Jay Berkenbilt 2017-08-25 22:26:53 -04:00
parent ad527a64f9
commit 021c229331

View File

@ -35,6 +35,20 @@ Pl_Flate::~Pl_Flate()
delete [] this->outbuf;
this->outbuf = 0;
}
if (this->initialized)
{
z_stream& zstream = *(static_cast<z_stream*>(this->zdata));
if (action == a_deflate)
{
deflateEnd(&zstream);
}
else
{
inflateEnd(&zstream);
}
}
delete static_cast<z_stream*>(this->zdata);
this->zdata = 0;
}
@ -174,6 +188,7 @@ Pl_Flate::finish()
{
err = inflateEnd(&zstream);
}
this->initialized = false;
checkError("End", err);
}