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
Родитель d2eff92f29
Коммит d72e4268d0
1 изменённых файлов: 4 добавлений и 0 удалений

4
netwerk/cache/nsCacheEntryDescriptor.cpp поставляемый
Просмотреть файл

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