Bug 712277 - Avoid crash in zlib adler32 following compression failure; r=michal.novotny

This commit is contained in:
Geoff Brown 2012-01-25 14:52:29 +01:00
parent b02e38d953
commit 66533c429e

View File

@ -915,6 +915,8 @@ nsCompressOutputStreamWrapper::Write(const char * buf,
while (mZstream.avail_in > 0) {
zerr = deflate(&mZstream, Z_NO_FLUSH);
if (zerr == Z_STREAM_ERROR) {
deflateEnd(&mZstream);
mStreamInitialized = PR_FALSE;
return NS_ERROR_FAILURE;
}
// Note: Z_BUF_ERROR is non-fatal and sometimes expected here.
@ -924,6 +926,8 @@ nsCompressOutputStreamWrapper::Write(const char * buf,
if (mZstream.avail_out == 0) {
rv = WriteBuffer();
if (NS_FAILED(rv)) {
deflateEnd(&mZstream);
mStreamInitialized = PR_FALSE;
return rv;
}
}