From 093b63034758fa8c85543afd6a93bcf1b6da231e Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 3 Jul 2018 04:26:29 +0200 Subject: Fix cache v1 compression crash in nsCompressOutputStreamWrapper::Close() --- netwerk/cache/nsCacheEntryDescriptor.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'netwerk') diff --git a/netwerk/cache/nsCacheEntryDescriptor.cpp b/netwerk/cache/nsCacheEntryDescriptor.cpp index b53ee3058..64765f8aa 100644 --- a/netwerk/cache/nsCacheEntryDescriptor.cpp +++ b/netwerk/cache/nsCacheEntryDescriptor.cpp @@ -1399,6 +1399,12 @@ nsCompressOutputStreamWrapper::Close() // Do not allow to initialize stream after calling Close(). mStreamEnded = true; + // In some rare cases, flushing the zlib stream can take too long + // and we lose our cache entry in the meantime. Do another check + // and bail if so. + if (!mDescriptor) + return NS_ERROR_NOT_AVAILABLE; + if (mDescriptor->CacheEntry()) { nsAutoCString uncompressedLenStr; rv = mDescriptor->GetMetaDataElement("uncompressed-len", -- cgit v1.2.3