Bug 1231378 - part 3 - Fix uninitialized members of classes in modules/libjar and mfbt, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 12 Jan 2016 18:16:59 +0000
changeset 279635 d8a738e7b8ffd83cd6071e66461791d8a2d3e673
parent 279634 824b152131b6076926df81931cb4ec1ee80aab97
child 279636 5f773a189557c1d6283a0ef218cc2d6b71e20c6e
push id29885
push usercbook@mozilla.com
push dateWed, 13 Jan 2016 10:57:28 +0000
treeherdermozilla-central@531d1f6d1cde [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1231378
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1231378 - part 3 - Fix uninitialized members of classes in modules/libjar and mfbt, r=smaug
mfbt/FastBernoulliTrial.h
mfbt/ThreadLocal.h
modules/libjar/nsJAR.cpp
modules/libjar/nsJAR.h
modules/libjar/nsJARChannel.cpp
modules/libjar/nsJARInputStream.h
modules/libjar/zipwriter/nsZipWriter.cpp
modules/libpref/nsPrefBranch.h
--- a/mfbt/FastBernoulliTrial.h
+++ b/mfbt/FastBernoulliTrial.h
@@ -172,17 +172,20 @@ class FastBernoulliTrial {
    */
  public:
   /**
    * Construct a fast Bernoulli trial generator. Calls to |trial()| return true
    * with probability |aProbability|. Use |aState0| and |aState1| to seed the
    * random number generator; both may not be zero.
    */
   FastBernoulliTrial(double aProbability, uint64_t aState0, uint64_t aState1)
-   : mGenerator(aState0, aState1)
+   : mProbability(0)
+   , mInvLogNotProbability(0)
+   , mGenerator(aState0, aState1)
+   , mSkipCount(0)
   {
     setProbability(aProbability);
   }
 
   /**
    * Return true with probability |mProbability|. Call this each time an event
    * occurs, to decide whether to sample it or not. The lower |mProbability| is,
    * the faster this function runs.
--- a/mfbt/ThreadLocal.h
+++ b/mfbt/ThreadLocal.h
@@ -90,16 +90,20 @@ class ThreadLocal
 
   template<typename S>
   struct Helper<S *>
   {
     typedef S *Type;
   };
 
 public:
+  ThreadLocal()
+    : mKey(0), mInited(false)
+  {}
+
   MOZ_WARN_UNUSED_RESULT inline bool init();
 
   inline T get() const;
 
   inline void set(const T aValue);
 
   bool initialized() const { return mInited; }
 
--- a/modules/libjar/nsJAR.cpp
+++ b/modules/libjar/nsJAR.cpp
@@ -79,16 +79,17 @@ nsJARManifestItem::~nsJARManifestItem()
 // The following initialization makes a guess of 10 entries per jarfile.
 nsJAR::nsJAR(): mZip(new nsZipArchive()),
                 mManifestData(8),
                 mParsedManifest(false),
                 mGlobalStatus(JAR_MANIFEST_NOT_PARSED),
                 mReleaseTime(PR_INTERVAL_NO_TIMEOUT),
                 mCache(nullptr),
                 mLock("nsJAR::mLock"),
+                mMtime(0),
                 mTotalItemsInManifest(0),
                 mOpened(false)
 {
 }
 
 nsJAR::~nsJAR()
 {
   Close();
@@ -1050,16 +1051,17 @@ nsJARItem::GetPermissions(uint32_t* aPer
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsIZipReaderCache
 
 NS_IMPL_ISUPPORTS(nsZipReaderCache, nsIZipReaderCache, nsIObserver, nsISupportsWeakReference)
 
 nsZipReaderCache::nsZipReaderCache()
   : mLock("nsZipReaderCache.mLock")
+  , mCacheSize(0)
   , mZips()
 #ifdef ZIP_CACHE_HIT_RATE
     ,
     mZipCacheLookups(0),
     mZipCacheHits(0),
     mZipCacheFlushes(0),
     mZipSyncMisses(0)
 #endif
--- a/modules/libjar/nsJAR.h
+++ b/modules/libjar/nsJAR.h
@@ -97,17 +97,17 @@ class nsJAR final : public nsIZipReader
     nsresult GetNSPRFileDesc(PRFileDesc** aNSPRFileDesc);
 
   protected:
     typedef nsClassHashtable<nsCStringHashKey, nsJARManifestItem> ManifestDataHashtable;
 
     //-- Private data members
     nsCOMPtr<nsIFile>        mZipFile;        // The zip/jar file on disk
     nsCString                mOuterZipEntry;  // The entry in the zip this zip is reading from
-    RefPtr<nsZipArchive>   mZip;            // The underlying zip archive
+    RefPtr<nsZipArchive>     mZip;            // The underlying zip archive
     ManifestDataHashtable    mManifestData;   // Stores metadata for each entry
     bool                     mParsedManifest; // True if manifest has been parsed
     nsCOMPtr<nsIX509Cert>    mSigningCert;    // The entity which signed this file
     int16_t                  mGlobalStatus;   // Global signature verification status
     PRIntervalTime           mReleaseTime;    // used by nsZipReaderCache for flushing entries
     nsZipReaderCache*        mCache;          // if cached, this points to the cache it's contained in
     mozilla::Mutex           mLock;
     int64_t                  mMtime;
@@ -161,17 +161,18 @@ private:
  * (based on a pattern match in its member nsZipFind).
  */
 class nsJAREnumerator final : public nsIUTF8StringEnumerator
 {
 public:
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIUTF8STRINGENUMERATOR
 
-    explicit nsJAREnumerator(nsZipFind *aFind) : mFind(aFind), mName(nullptr) {
+    explicit nsJAREnumerator(nsZipFind *aFind)
+      : mFind(aFind), mName(nullptr), mNameLen(0) {
       NS_ASSERTION(mFind, "nsJAREnumerator: Missing zipFind.");
     }
 
 private:
     nsZipFind    *mFind;
     const char*   mName;    // pointer to an name owned by mArchive -- DON'T delete
     uint16_t      mNameLen;
 
--- a/modules/libjar/nsJARChannel.cpp
+++ b/modules/libjar/nsJARChannel.cpp
@@ -190,16 +190,17 @@ nsJARInputThunk::IsNonBlocking(bool *non
 
 //-----------------------------------------------------------------------------
 // nsJARChannel
 //-----------------------------------------------------------------------------
 
 
 nsJARChannel::nsJARChannel()
     : mOpened(false)
+    , mContentDisposition(0)
     , mAppURI(nullptr)
     , mContentLength(-1)
     , mLoadFlags(LOAD_NORMAL)
     , mStatus(NS_OK)
     , mIsPending(false)
     , mIsUnsafe(true)
     , mOpeningRemote(false)
     , mSynthesizedStreamLength(0)
--- a/modules/libjar/nsJARInputStream.h
+++ b/modules/libjar/nsJARInputStream.h
@@ -16,18 +16,18 @@
  * Class nsJARInputStream declaration. This class defines the type of the
  * object returned by calls to nsJAR::GetInputStream(filename) for the
  * purpose of reading a file item out of a JAR file. 
  *------------------------------------------------------------------------*/
 class nsJARInputStream final : public nsIInputStream
 {
   public:
     nsJARInputStream() : 
-        mOutSize(0), mInCrc(0), mOutCrc(0), mCurPos(0),
-        mMode(MODE_NOTINITED)
+        mOutSize(0), mInCrc(0), mOutCrc(0), mNameLen(0),
+        mCurPos(0), mArrPos(0), mMode(MODE_NOTINITED)
     { 
       memset(&mZs, 0, sizeof(z_stream));
     }
 
     NS_DECL_THREADSAFE_ISUPPORTS
     NS_DECL_NSIINPUTSTREAM
    
     // takes ownership of |fd|, even on failure
@@ -42,17 +42,17 @@ class nsJARInputStream final : public ns
 
     RefPtr<nsZipHandle>  mFd;         // handle for reading
     uint32_t               mOutSize;    // inflated size 
     uint32_t               mInCrc;      // CRC as provided by the zipentry
     uint32_t               mOutCrc;     // CRC as calculated by me
     z_stream               mZs;         // zip data structure
 
     /* For directory reading */
-    RefPtr<nsJAR>        mJar;        // string reference to zipreader
+    RefPtr<nsJAR>          mJar;        // string reference to zipreader
     uint32_t               mNameLen;    // length of dirname
     nsCString              mBuffer;     // storage for generated text of stream
     uint32_t               mCurPos;     // Current position in buffer
     uint32_t               mArrPos;     // current position within mArray
     nsTArray<nsCString>    mArray;      // array of names in (zip) directory
 
 	typedef enum {
         MODE_NOTINITED,
--- a/modules/libjar/zipwriter/nsZipWriter.cpp
+++ b/modules/libjar/zipwriter/nsZipWriter.cpp
@@ -47,19 +47,20 @@ using namespace mozilla;
  * [file data n]
  * [central directory]
  * [end of central directory record]
  */
 NS_IMPL_ISUPPORTS(nsZipWriter, nsIZipWriter,
                   nsIRequestObserver)
 
 nsZipWriter::nsZipWriter()
-{
-    mInQueue = false;
-}
+  : mCDSOffset(0)
+  , mCDSDirty(false)
+  , mInQueue(false)
+{}
 
 nsZipWriter::~nsZipWriter()
 {
     if (mStream && !mInQueue)
         Close();
 }
 
 NS_IMETHODIMP nsZipWriter::GetComment(nsACString & aComment)
--- a/modules/libpref/nsPrefBranch.h
+++ b/modules/libpref/nsPrefBranch.h
@@ -195,17 +195,20 @@ public:
   static void NotifyObserver(const char *newpref, void *data);
 
   size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf);
 
 protected:
   virtual ~nsPrefBranch();
 
   nsPrefBranch()    /* disallow use of this constructer */
-    { }
+    : mPrefRootLength(0)
+    , mIsDefault(false)
+    , mFreeingObserverList(false)
+  {}
 
   nsresult   GetDefaultFromPropertiesFile(const char *aPrefName, char16_t **return_buf);
   // As SetCharPref, but without any check on the length of |aValue|
   nsresult   SetCharPrefInternal(const char *aPrefName, const char *aValue);
   // Reject strings that are more than 1Mb, warn if strings are more than 16kb
   nsresult   CheckSanityOfStringLength(const char* aPrefName, const nsAString& aValue);
   nsresult   CheckSanityOfStringLength(const char* aPrefName, const char* aValue);
   nsresult   CheckSanityOfStringLength(const char* aPrefName, const uint32_t aLength);