Bug 316661 - Part A - Remove null-checks before delete. r=bsmedberg
authorEd Morley <bmo@edmorley.co.uk>
Tue, 17 May 2011 16:01:36 +0200
changeset 69660 c8d5469bed72c3141ef8fcbb149151bf8eeab5f1
parent 69659 dfb4cebe8c9553a20175a236157882c428c8c7f6
child 69661 469863836e29790de745e1cc88f2d8f3690fd7a1
push id20060
push usermlamouri@mozilla.com
push dateWed, 18 May 2011 09:43:43 +0000
treeherdermozilla-central@4aad8ef5c011 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs316661
milestone6.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 316661 - Part A - Remove null-checks before delete. r=bsmedberg
accessible/src/atk/nsAccessibleWrap.cpp
content/xul/document/src/nsXULControllers.cpp
dom/plugins/ipc/PluginInstanceParent.cpp
editor/txmgr/src/nsTransactionItem.cpp
embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp
extensions/universalchardet/src/base/nsUniversalDetector.cpp
gfx/ipc/SharedDIB.cpp
gfx/thebes/gfxFont.cpp
gfx/thebes/gfxOS2Fonts.cpp
layout/generic/nsObjectFrame.cpp
layout/generic/nsSimplePageSequence.cpp
layout/mathml/nsMathMLChar.cpp
layout/mathml/nsMathMLmfencedFrame.cpp
modules/libpr0n/src/RasterImage.cpp
netwerk/base/src/nsProtocolProxyService.cpp
netwerk/cache/nsCacheService.cpp
parser/html/nsHtml5Tokenizer.cpp
parser/htmlparser/src/nsDTDUtils.cpp
parser/htmlparser/src/nsScanner.cpp
security/manager/ssl/src/nsCertTree.cpp
widget/src/xpwidgets/nsBaseWidget.cpp
xpcom/glue/nsDeque.cpp
xpcom/io/nsStorageStream.cpp
xpcom/tests/TestTimers.cpp
xpinstall/src/nsXPITriggerInfo.cpp
--- a/accessible/src/atk/nsAccessibleWrap.cpp
+++ b/accessible/src/atk/nsAccessibleWrap.cpp
@@ -336,19 +336,17 @@ void nsAccessibleWrap::SetMaiHyperlink(M
 {
     NS_ASSERTION(quark_mai_hyperlink, "quark_mai_hyperlink not initialized");
     NS_ASSERTION(IS_MAI_OBJECT(mAtkObject), "Invalid AtkObject");
     if (quark_mai_hyperlink && IS_MAI_OBJECT(mAtkObject)) {
         MaiHyperlink* maiHyperlink = GetMaiHyperlink(PR_FALSE);
         if (!maiHyperlink && !aMaiHyperlink) {
             return; // Never set and we're shutting down
         }
-        if (maiHyperlink) {
-            delete maiHyperlink;
-        }
+        delete maiHyperlink;
         g_object_set_qdata(G_OBJECT(mAtkObject), quark_mai_hyperlink,
                            aMaiHyperlink);
     }
 }
 
 NS_IMETHODIMP nsAccessibleWrap::GetNativeInterface(void **aOutAccessible)
 {
     *aOutAccessible = nsnull;
--- a/content/xul/document/src/nsXULControllers.cpp
+++ b/content/xul/document/src/nsXULControllers.cpp
@@ -66,18 +66,17 @@ nsXULControllers::~nsXULControllers(void
 
 void
 nsXULControllers::DeleteControllers()
 {
   PRUint32 count = mControllers.Length();
   for (PRUint32 i = 0; i < count; i++)
   {
     nsXULControllerData* controllerData = mControllers.ElementAt(i);
-    if (controllerData)
-      delete controllerData;    // releases the nsIController
+    delete controllerData;    // releases the nsIController
   }
   
   mControllers.Clear();
 }
 
 
 nsresult
 NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult)
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -136,18 +136,17 @@ PluginInstanceParent::~PluginInstancePar
         "Subclass was not reset correctly before the dtor was reached!");
 #endif
 #if defined(OS_MACOSX)
     if (mShWidth != 0 && mShHeight != 0) {
         DeallocShmem(mShSurface);
     }
     if (mShColorSpace)
         ::CGColorSpaceRelease(mShColorSpace);
-    if (mIOSurface)
-        delete mIOSurface;
+    delete mIOSurface;
     if (mDrawingModel == NPDrawingModelCoreAnimation) {
         mParent->RemoveFromRefreshTimer(this);
     }
 #endif
 }
 
 bool
 PluginInstanceParent::Init()
@@ -865,19 +864,17 @@ PluginInstanceParent::NPP_SetWindow(cons
     window.clipRect = aWindow->clipRect; // MacOS specific
     window.type = aWindow->type;
 #endif
 
 #if defined(XP_MACOSX)
     if (mShWidth != window.width || mShHeight != window.height) {
         if (mDrawingModel == NPDrawingModelCoreAnimation || 
             mDrawingModel == NPDrawingModelInvalidatingCoreAnimation) {
-            if (mIOSurface) {
-                delete mIOSurface;
-            }
+            delete mIOSurface;
             mIOSurface = nsIOSurface::CreateIOSurface(window.width, window.height);
         } else if (mShWidth * mShHeight != window.width * window.height) {
             if (mShWidth != 0 && mShHeight != 0) {
                 DeallocShmem(mShSurface);
                 mShWidth = 0;
                 mShHeight = 0;
             }
 
--- a/editor/txmgr/src/nsTransactionItem.cpp
+++ b/editor/txmgr/src/nsTransactionItem.cpp
@@ -44,21 +44,19 @@
 
 nsTransactionItem::nsTransactionItem(nsITransaction *aTransaction)
     : mTransaction(aTransaction), mUndoStack(0), mRedoStack(0)
 {
 }
 
 nsTransactionItem::~nsTransactionItem()
 {
-  if (mRedoStack)
-    delete mRedoStack;
+  delete mRedoStack;
 
-  if (mUndoStack)
-    delete mUndoStack;
+  delete mUndoStack;
 }
 
 nsrefcnt
 nsTransactionItem::AddRef()
 {
   ++mRefCnt;
   NS_LOG_ADDREF(this, mRefCnt, "nsTransactionItem",
                 sizeof(nsTransactionItem));
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
+++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
@@ -2576,51 +2576,42 @@ nsWebBrowserPersist::EnumCleanupOutputMa
     nsCOMPtr<nsISupports> keyPtr;
     ((nsMyISupportsKey *) aKey)->GetISupports(getter_AddRefs(keyPtr));
     nsCOMPtr<nsIChannel> channel = do_QueryInterface(keyPtr);
     if (channel)
     {
         channel->Cancel(NS_BINDING_ABORTED);
     }
     OutputData *data = (OutputData *) aData;
-    if (data)
-    {
-        delete data;
-    }
+    delete data;
     return PR_TRUE;
 }
 
 
 PRBool
 nsWebBrowserPersist::EnumCleanupURIMap(nsHashKey *aKey, void *aData, void* closure)
 {
     URIData *data = (URIData *) aData;
-    if (data)
-    {
-        delete data; // Delete data associated with key
-    }
+    delete data; // Delete data associated with key
     return PR_TRUE;
 }
 
 
 PRBool
 nsWebBrowserPersist::EnumCleanupUploadList(nsHashKey *aKey, void *aData, void* closure)
 {
     nsCOMPtr<nsISupports> keyPtr;
     ((nsMyISupportsKey *) aKey)->GetISupports(getter_AddRefs(keyPtr));
     nsCOMPtr<nsIChannel> channel = do_QueryInterface(keyPtr);
     if (channel)
     {
         channel->Cancel(NS_BINDING_ABORTED);
     }
     UploadData *data = (UploadData *) aData;
-    if (data)
-    {
-        delete data; // Delete data associated with key
-    }
+    delete data; // Delete data associated with key
     return PR_TRUE;
 }
 
 
 PRBool
 nsWebBrowserPersist::GetQuotedAttributeValue(
     const nsAString &aSource, const nsAString &aAttribute, nsAString &aValue)
 {  
--- a/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp
+++ b/extensions/pref/system-pref/src/gconf/nsSystemPrefService.cpp
@@ -228,18 +228,17 @@ nsSystemPrefService::nsSystemPrefService
      mObservers(nsnull)
 {
 }
 
 nsSystemPrefService::~nsSystemPrefService()
 {
     mInitialized = PR_FALSE;
 
-    if (mGConf)
-        delete mGConf;
+    delete mGConf;
     if (mObservers) {
         (void)mObservers->EnumerateForwards(sysPrefDeleteObserver, nsnull);
         delete mObservers;
     }
 }
 
 nsresult
 nsSystemPrefService::Init()
--- a/extensions/universalchardet/src/base/nsUniversalDetector.cpp
+++ b/extensions/universalchardet/src/base/nsUniversalDetector.cpp
@@ -62,20 +62,19 @@ nsUniversalDetector::nsUniversalDetector
   PRUint32 i;
   for (i = 0; i < NUM_OF_CHARSET_PROBERS; i++)
     mCharSetProbers[i] = nsnull;
 }
 
 nsUniversalDetector::~nsUniversalDetector() 
 {
   for (PRInt32 i = 0; i < NUM_OF_CHARSET_PROBERS; i++)
-    if (mCharSetProbers[i])      
-      delete mCharSetProbers[i];
-  if (mEscCharSetProber)
-    delete mEscCharSetProber;
+    delete mCharSetProbers[i];
+
+  delete mEscCharSetProber;
 }
 
 void 
 nsUniversalDetector::Reset()
 {
   mDone = PR_FALSE;
   mBestGuess = -1;   //illegal value as signal
   mInTag = PR_FALSE;
--- a/gfx/ipc/SharedDIB.cpp
+++ b/gfx/ipc/SharedDIB.cpp
@@ -70,18 +70,17 @@ SharedDIB::IsValid()
     return false;
 
   return mShMem->IsHandleValid(mShMem->handle());
 }
 
 nsresult
 SharedDIB::Close()
 {
-  if (mShMem)
-    delete mShMem;
+  delete mShMem;
 
   mShMem = nsnull;
 
   return NS_OK;
 }
 
 nsresult
 SharedDIB::Attach(Handle aHandle, PRUint32 aSize)
--- a/gfx/thebes/gfxFont.cpp
+++ b/gfx/thebes/gfxFont.cpp
@@ -91,19 +91,17 @@ static PRUint32 gGlyphExtentsWidthsTotal
 static PRUint32 gGlyphExtentsSetupEagerSimple = 0;
 static PRUint32 gGlyphExtentsSetupEagerTight = 0;
 static PRUint32 gGlyphExtentsSetupLazyTight = 0;
 static PRUint32 gGlyphExtentsSetupFallBackToTight = 0;
 #endif
 
 gfxFontEntry::~gfxFontEntry() 
 {
-    if (mUserFontData) {
-        delete mUserFontData;
-    }
+    delete mUserFontData;
 }
 
 PRBool gfxFontEntry::TestCharacterMap(PRUint32 aCh)
 {
     if (!mCmapInitialized) {
         ReadCMAP();
     }
     return mCharacterMap.test(aCh);
--- a/gfx/thebes/gfxOS2Fonts.cpp
+++ b/gfx/thebes/gfxOS2Fonts.cpp
@@ -92,19 +92,17 @@ gfxOS2Font::~gfxOS2Font()
     printf("gfxOS2Font[%#x]::~gfxOS2Font()\n", (unsigned)this);
 #endif
     if (mFontFace) {
         cairo_font_face_destroy(mFontFace);
     }
     if (mScaledFont) {
         cairo_scaled_font_destroy(mScaledFont);
     }
-    if (mMetrics) {
-        delete mMetrics;
-    }
+    delete mMetrics;
     mFontFace = nsnull;
     mScaledFont = nsnull;
     mMetrics = nsnull;
 }
 
 // fill font metrics structure with default values in case of error
 static void FillMetricsDefaults(gfxFont::Metrics *aMetrics)
 {
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -4388,19 +4388,17 @@ void nsPluginInstanceOwner::RenderCoreAn
                                                 int aWidth, int aHeight)
 {
   if (aWidth == 0 || aHeight == 0)
     return;
 
   if (!mIOSurface || 
       (mIOSurface->GetWidth() != (size_t)aWidth || 
        mIOSurface->GetHeight() != (size_t)aHeight)) {
-    if (mIOSurface) {
-      delete mIOSurface;
-    }
+    delete mIOSurface;
 
     // If the renderer is backed by an IOSurface, resize it as required.
     mIOSurface = nsIOSurface::CreateIOSurface(aWidth, aHeight);
     if (mIOSurface) {
       nsIOSurface *attachSurface = nsIOSurface::LookupSurface(
                                       mIOSurface->GetIOSurfaceID());
       if (attachSurface) {
         mCARenderer.AttachIOSurface(attachSurface);
@@ -5760,18 +5758,17 @@ nsresult
 nsPluginInstanceOwner::Destroy()
 {
 #ifdef MAC_CARBON_PLUGINS
   // stop the timer explicitly to reduce reference count.
   CancelTimer();
 #endif
 #ifdef XP_MACOSX
   RemoveFromCARefreshTimer(this);
-  if (mIOSurface)
-    delete mIOSurface;
+  delete mIOSurface;
   if (mColorProfile)
     ::CGColorSpaceRelease(mColorProfile);  
 #endif
 
   // unregister context menu listener
   if (mCXMenuListener) {
     mCXMenuListener->Destroy(mContent);
     mCXMenuListener = nsnull;
--- a/layout/generic/nsSimplePageSequence.cpp
+++ b/layout/generic/nsSimplePageSequence.cpp
@@ -90,17 +90,17 @@ nsSharedPageData::nsSharedPageData() :
   mPageContentXMost(0),
   mPageContentSize(0)
 {
 }
 
 nsSharedPageData::~nsSharedPageData()
 {
   nsMemory::Free(mDateTimeStr);
-  if (mHeadFootFont) delete mHeadFootFont;
+  delete mHeadFootFont;
   nsMemory::Free(mPageNumFormat);
   nsMemory::Free(mPageNumAndTotalsFormat);
   if (mDocTitle) nsMemory::Free(mDocTitle);
   if (mDocURL) nsMemory::Free(mDocURL);
 }
 
 nsIFrame*
 NS_NewSimplePageSequenceFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
@@ -129,17 +129,17 @@ nsSimplePageSequenceFrame::nsSimplePageS
 
   // Doing this here so we only have to go get these formats once
   SetPageNumberFormat("pagenumber",  "%1$d", PR_TRUE);
   SetPageNumberFormat("pageofpages", "%1$d of %2$d", PR_FALSE);
 }
 
 nsSimplePageSequenceFrame::~nsSimplePageSequenceFrame()
 {
-  if (mPageData) delete mPageData;
+  delete mPageData;
 }
 
 NS_QUERYFRAME_HEAD(nsSimplePageSequenceFrame)
   NS_QUERYFRAME_ENTRY(nsIPageSequenceFrame)
 NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
 
 //----------------------------------------------------------------------
 
--- a/layout/mathml/nsMathMLChar.cpp
+++ b/layout/mathml/nsMathMLChar.cpp
@@ -1766,21 +1766,16 @@ nsMathMLChar::ComposeChildren(nsPresCont
   // otherwise, use what we have, adding more children as needed or deleting the extra
   nsMathMLChar* last = this;
   while ((i < count) && last->mSibling) {
     i++;
     last = last->mSibling;
   }
   while (i < count) {
     child = new nsMathMLChar(this);
-    if (!child) {
-      if (mSibling) delete mSibling; // don't leave a dangling list ...
-      mSibling = nsnull;
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
     last->mSibling = child;
     last = child;
     i++;
   }
   if (last->mSibling) {
     delete last->mSibling;
     last->mSibling = nsnull;
   }
--- a/layout/mathml/nsMathMLmfencedFrame.cpp
+++ b/layout/mathml/nsMathMLmfencedFrame.cpp
@@ -114,18 +114,18 @@ nsMathMLmfencedFrame::ChildListChanged(P
   CreateFencesAndSeparators(PresContext());
 
   return nsMathMLContainerFrame::ChildListChanged(aModType);
 }
 
 void
 nsMathMLmfencedFrame::RemoveFencesAndSeparators()
 {
-  if (mOpenChar) delete mOpenChar;
-  if (mCloseChar) delete mCloseChar;
+  delete mOpenChar;
+  delete mCloseChar;
   if (mSeparatorsChar) delete[] mSeparatorsChar;
 
   mOpenChar = nsnull;
   mCloseChar = nsnull;
   mSeparatorsChar = nsnull;
   mSeparatorsCount = 0;
 }
 
--- a/modules/libpr0n/src/RasterImage.cpp
+++ b/modules/libpr0n/src/RasterImage.cpp
@@ -210,18 +210,17 @@ RasterImage::RasterImage(imgStatusTracke
 
   // Statistics
   num_containers++;
 }
 
 //******************************************************************************
 RasterImage::~RasterImage()
 {
-  if (mAnim)
-    delete mAnim;
+  delete mAnim;
 
   for (unsigned int i = 0; i < mFrames.Length(); ++i)
     delete mFrames[i];
 
   // Discardable statistics
   if (mDiscardable) {
     num_discardable_containers--;
     discardable_source_bytes -= mSourceData.Length();
--- a/netwerk/base/src/nsProtocolProxyService.cpp
+++ b/netwerk/base/src/nsProtocolProxyService.cpp
@@ -1171,18 +1171,17 @@ nsProtocolProxyService::LoadHostFilters(
         else {
             printf("  name.host = %s\n", hinfo->name.host);
         }
 #endif
 
         mHostFiltersArray.AppendElement(hinfo);
         hinfo = nsnull;
 loser:
-        if (hinfo)
-            delete hinfo;
+        delete hinfo;
     }
 }
 
 nsresult
 nsProtocolProxyService::GetProtocolInfo(nsIURI *uri, nsProtocolInfo *info)
 {
     nsresult rv;
 
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -1733,19 +1733,17 @@ nsCacheService::ActivateEntry(nsCacheReq
         CACHE_LOG_DEBUG(("Added entry %p to mActiveEntries\n", entry));
         entry->MarkActive();  // mark entry active, because it's now in mActiveEntries
     }
     *result = entry;
     return NS_OK;
     
  error:
     *result = nsnull;
-    if (entry) {
-        delete entry;
-    }
+    delete entry;
     return rv;
 }
 
 
 nsCacheEntry *
 nsCacheService::SearchCacheDevices(nsCString * key, nsCacheStoragePolicy policy, PRBool *collision)
 {
     nsCacheEntry * entry = nsnull;
--- a/parser/html/nsHtml5Tokenizer.cpp
+++ b/parser/html/nsHtml5Tokenizer.cpp
@@ -3853,19 +3853,17 @@ nsHtml5Tokenizer::loadState(nsHtml5Token
   if (attributeName) {
     attributeName->release();
   }
   if (!other->attributeName) {
     attributeName = nsnull;
   } else {
     attributeName = other->attributeName->cloneAttributeName(interner);
   }
-  if (attributes) {
-    delete attributes;
-  }
+  delete attributes;
   if (!other->attributes) {
     attributes = nsnull;
   } else {
     attributes = other->attributes->cloneAttributes(interner);
   }
 }
 
 void 
--- a/parser/htmlparser/src/nsDTDUtils.cpp
+++ b/parser/htmlparser/src/nsDTDUtils.cpp
@@ -1036,19 +1036,17 @@ NS_IMPL_ISUPPORTS1(nsObserverEntry, nsIO
 
 nsObserverEntry::nsObserverEntry(const nsAString& aTopic) : mTopic(aTopic) 
 {
   memset(mObservers, 0, sizeof(mObservers));
 }
 
 nsObserverEntry::~nsObserverEntry() {
   for (PRInt32 i = 0; i <= NS_HTML_TAG_MAX; ++i){
-    if (mObservers[i]) {
-      delete mObservers[i];
-    }
+    delete mObservers[i];
   }
 }
 
 NS_IMETHODIMP
 nsObserverEntry::Notify(nsIParserNode* aNode,
                         nsIParser* aParser,
                         nsISupports* aDocShell,
                         const PRUint32 aFlags) 
--- a/parser/htmlparser/src/nsScanner.cpp
+++ b/parser/htmlparser/src/nsScanner.cpp
@@ -204,19 +204,17 @@ nsresult nsScanner::SetDocumentCharset(c
  *  default destructor
  *  
  *  @update  gess 3/25/98
  *  @param   
  *  @return  
  */
 nsScanner::~nsScanner() {
 
-  if (mSlidingBuffer) {
-    delete mSlidingBuffer;
-  }
+  delete mSlidingBuffer;
 
   MOZ_COUNT_DTOR(nsScanner);
 }
 
 /**
  *  Resets current offset position of input stream to marked position. 
  *  This allows us to back up to this point if the need should arise, 
  *  such as when tokenization gets interrupted.
--- a/security/manager/ssl/src/nsCertTree.cpp
+++ b/security/manager/ssl/src/nsCertTree.cpp
@@ -80,19 +80,17 @@ struct treeArrayElStr {
 
 CompareCacheHashEntryPtr::CompareCacheHashEntryPtr()
 {
   entry = new CompareCacheHashEntry;
 }
 
 CompareCacheHashEntryPtr::~CompareCacheHashEntryPtr()
 {
-  if (entry) {
-    delete entry;
-  }
+  delete entry;
 }
 
 CompareCacheHashEntry::CompareCacheHashEntry()
 :key(nsnull)
 {
   for (int i = 0; i < max_criterions; ++i) {
     mCritInit[i] = PR_FALSE;
   }
--- a/widget/src/xpwidgets/nsBaseWidget.cpp
+++ b/widget/src/xpwidgets/nsBaseWidget.cpp
@@ -146,18 +146,17 @@ nsBaseWidget::~nsBaseWidget()
 
 #ifdef NOISY_WIDGET_LEAKS
   gNumWidgets--;
   printf("WIDGETS- = %d\n", gNumWidgets);
 #endif
 
   NS_IF_RELEASE(mToolkit);
   NS_IF_RELEASE(mContext);
-  if (mOriginalBounds)
-    delete mOriginalBounds;
+  delete mOriginalBounds;
 }
 
 
 //-------------------------------------------------------------------------
 //
 // Basic create.
 //
 //-------------------------------------------------------------------------
--- a/xpcom/glue/nsDeque.cpp
+++ b/xpcom/glue/nsDeque.cpp
@@ -124,19 +124,17 @@ nsDeque::~nsDeque() {
 
 /**
  * Set the functor to be called by Erase()
  * The deque owns the functor.
  *
  * @param   aDeallocator functor object for use by Erase()
  */
 void nsDeque::SetDeallocator(nsDequeFunctor* aDeallocator){
-  if (mDeallocator) {
-    delete mDeallocator;
-  }
+  delete mDeallocator;
   mDeallocator=aDeallocator;
 }
 
 /**
  * Remove all items from container without destroying them.
  *
  * @return  *this
  */
--- a/xpcom/io/nsStorageStream.cpp
+++ b/xpcom/io/nsStorageStream.cpp
@@ -75,18 +75,17 @@ nsStorageStream::nsStorageStream()
     : mSegmentedBuffer(0), mSegmentSize(0), mWriteInProgress(PR_FALSE),
       mLastSegmentNum(-1), mWriteCursor(0), mSegmentEnd(0), mLogicalLength(0)
 {
     LOG(("Creating nsStorageStream [%p].\n", this));
 }
 
 nsStorageStream::~nsStorageStream()
 {
-    if (mSegmentedBuffer)
-        delete mSegmentedBuffer;
+    delete mSegmentedBuffer;
 }
 
 NS_IMPL_THREADSAFE_ISUPPORTS2(nsStorageStream,
                               nsIStorageStream,
                               nsIOutputStream)
 
 NS_IMETHODIMP
 nsStorageStream::Init(PRUint32 segmentSize, PRUint32 maxSize,
--- a/xpcom/tests/TestTimers.cpp
+++ b/xpcom/tests/TestTimers.cpp
@@ -84,19 +84,17 @@ class AutoCreateAndDestroyReentrantMonit
 {
 public:
   AutoCreateAndDestroyReentrantMonitor() {
     mReentrantMonitor = new ReentrantMonitor("TestTimers::AutoMon");
     NS_ASSERTION(mReentrantMonitor, "Out of memory!");
   }
 
   ~AutoCreateAndDestroyReentrantMonitor() {
-    if (mReentrantMonitor) {
-      delete mReentrantMonitor;
-    }
+    delete mReentrantMonitor;
   }
 
   operator ReentrantMonitor* () {
     return mReentrantMonitor;
   }
 
 private:
   ReentrantMonitor* mReentrantMonitor;
--- a/xpinstall/src/nsXPITriggerInfo.cpp
+++ b/xpinstall/src/nsXPITriggerInfo.cpp
@@ -183,18 +183,17 @@ nsXPITriggerInfo::nsXPITriggerInfo()
 
 nsXPITriggerInfo::~nsXPITriggerInfo()
 {
     nsXPITriggerItem* item;
 
     for(PRUint32 i=0; i < Size(); i++)
     {
         item = Get(i);
-        if (item)
-            delete item;
+        delete item;
     }
     mItems.Clear();
 
     if ( mCx && !JSVAL_IS_NULL(mCbval) ) {
         JS_BeginRequest(mCx);
         JS_RemoveValueRoot(mCx, &mCbval );
         JS_EndRequest(mCx);
     }