diff --git a/modules/libjar/nsJARChannel.cpp b/modules/libjar/nsJARChannel.cpp index 059c2287112a..9e1a3cff7ca3 100644 --- a/modules/libjar/nsJARChannel.cpp +++ b/modules/libjar/nsJARChannel.cpp @@ -77,6 +77,7 @@ class nsJARInputThunk : public nsIInputStream { mJarReader(zipReader), mJarEntry(jarEntry), mContentLength(-1) { + MOZ_DIAGNOSTIC_ASSERT(zipReader, "zipReader must not be null"); if (ENTRY_IS_DIRECTORY(mJarEntry) && fullJarURI) { nsCOMPtr urlWithoutQueryRef; nsresult rv = NS_MutateURI(fullJarURI) @@ -110,6 +111,9 @@ class nsJARInputThunk : public nsIInputStream { NS_IMPL_ISUPPORTS(nsJARInputThunk, nsIInputStream) nsresult nsJARInputThunk::Init() { + if (!mJarReader) { + return NS_ERROR_INVALID_ARG; + } nsresult rv; if (ENTRY_IS_DIRECTORY(mJarEntry)) { // A directory stream also needs the Spec of the FullJarURI diff --git a/modules/libjar/nsJARInputStream.cpp b/modules/libjar/nsJARInputStream.cpp index ae202724d0d9..a47bd7a09fd7 100644 --- a/modules/libjar/nsJARInputStream.cpp +++ b/modules/libjar/nsJARInputStream.cpp @@ -35,7 +35,10 @@ NS_IMPL_ISUPPORTS(nsJARInputStream, nsIInputStream) nsresult nsJARInputStream::InitFile(nsZipHandle* aFd, const uint8_t* aData, nsZipItem* aItem) { nsresult rv = NS_OK; - MOZ_ASSERT(aFd, "Argument may not be null"); + MOZ_DIAGNOSTIC_ASSERT(aFd, "Argument may not be null"); + if (!aFd) { + return NS_ERROR_INVALID_ARG; + } MOZ_ASSERT(aItem, "Argument may not be null"); // Mark it as closed, in case something fails in initialisation diff --git a/modules/libjar/nsZipArchive.cpp b/modules/libjar/nsZipArchive.cpp index 1dcfd57c6595..1f43a0d6259c 100644 --- a/modules/libjar/nsZipArchive.cpp +++ b/modules/libjar/nsZipArchive.cpp @@ -766,6 +766,7 @@ nsZipHandle* nsZipArchive::GetFD() const { return mFd.get(); } //--------------------------------------------- uint32_t nsZipArchive::GetDataOffset(nsZipItem* aItem) { MOZ_ASSERT(aItem); + MOZ_DIAGNOSTIC_ASSERT(mFd); uint32_t offset; MMAP_FAULT_HANDLER_BEGIN_HANDLE(mFd) @@ -809,7 +810,10 @@ uint32_t nsZipArchive::GetDataOffset(nsZipItem* aItem) { // nsZipArchive::GetData //--------------------------------------------- const uint8_t* nsZipArchive::GetData(nsZipItem* aItem) { - MOZ_ASSERT(aItem); + MOZ_DIAGNOSTIC_ASSERT(aItem); + if (!aItem) { + return nullptr; + } uint32_t offset = GetDataOffset(aItem); MMAP_FAULT_HANDLER_BEGIN_HANDLE(mFd) @@ -838,6 +842,7 @@ nsZipArchive::nsZipArchive(nsZipHandle* aZipHandle, PRFileDesc* aFd, : mRefCnt(0), mFd(aZipHandle), mUseZipLog(false), mBuiltSynthetics(false) { // initialize the table to nullptr memset(mFiles, 0, sizeof(mFiles)); + MOZ_DIAGNOSTIC_ASSERT(aZipHandle); //-- get table of contents for archive aRv = BuildFileList(aFd);