From 51d11d89ea2a2c397df8f8510a05bd538390c02f Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Tue, 20 Oct 2015 13:32:47 +0200 Subject: [PATCH] Bug 1214782, r=ehsan --HG-- extra : rebase_source : f1dec852aa864b681b4417467992c7431f9103bf --- modules/libjar/nsZipArchive.cpp | 39 ++++++++++++++++++++++----------- modules/libjar/nsZipArchive.h | 20 +++++++++++------ 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/modules/libjar/nsZipArchive.cpp b/modules/libjar/nsZipArchive.cpp index c93f59196d15..7ed91ba7fdea 100644 --- a/modules/libjar/nsZipArchive.cpp +++ b/modules/libjar/nsZipArchive.cpp @@ -873,6 +873,8 @@ int64_t nsZipArchive::SizeOfMapping() nsZipArchive::nsZipArchive() : mRefCnt(0) + , mCommentPtr(nullptr) + , mCommentLen(0) , mBuiltSynthetics(false) { zipLog.AddRef(); @@ -900,12 +902,12 @@ nsZipArchive::~nsZipArchive() // nsZipFind constructor and destructor //------------------------------------------ -nsZipFind::nsZipFind(nsZipArchive* aZip, char* aPattern, bool aRegExp) : - mArchive(aZip), - mPattern(aPattern), - mItem(0), - mSlot(0), - mRegExp(aRegExp) +nsZipFind::nsZipFind(nsZipArchive* aZip, char* aPattern, bool aRegExp) + : mArchive(aZip) + , mPattern(aPattern) + , mItem(nullptr) + , mSlot(0) + , mRegExp(aRegExp) { MOZ_COUNT_CTOR(nsZipFind); } @@ -997,6 +999,13 @@ static PRTime GetModTime(uint16_t aDate, uint16_t aTime) return PR_ImplodeTime(&time); } +nsZipItem::nsZipItem() + : next(nullptr) + , central(nullptr) + , nameLength(0) + , isSynthetic(false) +{} + uint32_t nsZipItem::LocalOffset() { return xtolong(central->localhdr_offset); @@ -1092,11 +1101,13 @@ bool nsZipItem::IsSymlink() } #endif -nsZipCursor::nsZipCursor(nsZipItem *item, nsZipArchive *aZip, uint8_t* aBuf, uint32_t aBufSize, bool doCRC) : - mItem(item), - mBuf(aBuf), - mBufSize(aBufSize), - mDoCRC(doCRC) +nsZipCursor::nsZipCursor(nsZipItem *item, nsZipArchive *aZip, uint8_t* aBuf, + uint32_t aBufSize, bool doCRC) + : mItem(item) + , mBuf(aBuf) + , mBufSize(aBufSize) + , mCRC(0) + , mDoCRC(doCRC) { if (mItem->Compression() == DEFLATED) { #ifdef DEBUG @@ -1168,8 +1179,10 @@ MOZ_WIN_MEM_TRY_CATCH(return nullptr) return buf; } -nsZipItemPtr_base::nsZipItemPtr_base(nsZipArchive *aZip, const char * aEntryName, bool doCRC) : - mReturnBuf(nullptr) +nsZipItemPtr_base::nsZipItemPtr_base(nsZipArchive *aZip, + const char * aEntryName, bool doCRC) + : mReturnBuf(nullptr) + , mReadlen(0) { // make sure the ziparchive hangs around mZipHandle = aZip->GetFD(); diff --git a/modules/libjar/nsZipArchive.h b/modules/libjar/nsZipArchive.h index d66545f8904e..b29d7e0f875d 100644 --- a/modules/libjar/nsZipArchive.h +++ b/modules/libjar/nsZipArchive.h @@ -58,9 +58,11 @@ struct PRFileDesc; * each nsZipItem represents one file in the archive and all the * information needed to manipulate it. */ -class nsZipItem +class nsZipItem final { public: + nsZipItem(); + const char* Name() { return ((const char*)central) + ZIPCENTRAL_SIZE; } uint32_t LocalOffset(); @@ -91,7 +93,7 @@ class nsZipHandle; * nsZipArchive -- a class for reading the PKZIP file format. * */ -class nsZipArchive +class nsZipArchive final { friend class nsZipFind; @@ -241,7 +243,7 @@ private: * * a helper class for nsZipArchive, representing a search */ -class nsZipFind +class nsZipFind final { public: nsZipFind(nsZipArchive* aZip, char* aPattern, bool regExp); @@ -263,7 +265,8 @@ private: /** * nsZipCursor -- a low-level class for reading the individual items in a zip. */ -class nsZipCursor { +class nsZipCursor final +{ public: /** * Initializes the cursor @@ -318,7 +321,8 @@ private: * for decompression. * Do not use when the file may be very large. */ -class nsZipItemPtr_base { +class nsZipItemPtr_base +{ public: /** * Initializes the reader @@ -341,7 +345,8 @@ protected: }; template -class nsZipItemPtr : public nsZipItemPtr_base { +class nsZipItemPtr final : public nsZipItemPtr_base +{ public: nsZipItemPtr(nsZipArchive *aZip, const char *aEntryName, bool doCRC = false) : nsZipItemPtr_base(aZip, aEntryName, doCRC) { } /** @@ -376,7 +381,8 @@ public: } }; -class nsZipHandle { +class nsZipHandle final +{ friend class nsZipArchive; friend class mozilla::FileLocation; public: