Bug 845234 - Add null check in VectorImage's listener Cancel methods. r=dholbert
authorSeth Fowler <seth@mozilla.com>
Tue, 26 Feb 2013 13:21:07 -0800
changeset 123081 b6e113cd3eb0ba3032cbcf5264d762c6b71bad71
parent 123080 215273993b1f84a6cacbe60b64a7f4ebe8997692
child 123082 ce21cc14287762b6db3d526094ef4f36bca8bf7d
push id24372
push useremorley@mozilla.com
push dateWed, 27 Feb 2013 13:22:59 +0000
treeherdermozilla-central@0a91da5f5eab [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs845234
milestone22.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 845234 - Add null check in VectorImage's listener Cancel methods. r=dholbert
image/src/VectorImage.cpp
--- a/image/src/VectorImage.cpp
+++ b/image/src/VectorImage.cpp
@@ -129,18 +129,20 @@ public:
     nsRefPtr<SVGParseCompleteListener> kungFuDeathGroup(this);
 
     mImage->OnSVGDocumentParsed();
   }
 
   void Cancel()
   {
     NS_ABORT_IF_FALSE(mDocument, "Duplicate call to Cancel");
-    mDocument->RemoveObserver(this);
-    mDocument = nullptr;
+    if (mDocument) {
+      mDocument->RemoveObserver(this);
+      mDocument = nullptr;
+    }
   }
 
 private:
   nsCOMPtr<nsIDocument> mDocument;
   VectorImage* mImage; // Raw pointer to owner.
 };
 
 NS_IMPL_ISUPPORTS1(SVGParseCompleteListener, nsIDocumentObserver)
@@ -194,20 +196,22 @@ public:
     }
 
     return NS_OK;
   }
 
   void Cancel()
   {
     NS_ABORT_IF_FALSE(mDocument, "Duplicate call to Cancel");
-    mDocument->RemoveEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), this, true);
-    mDocument->RemoveEventListener(NS_LITERAL_STRING("SVGAbort"), this, true);
-    mDocument->RemoveEventListener(NS_LITERAL_STRING("SVGError"), this, true);
-    mDocument = nullptr;
+    if (mDocument) {
+      mDocument->RemoveEventListener(NS_LITERAL_STRING("MozSVGAsImageDocumentLoad"), this, true);
+      mDocument->RemoveEventListener(NS_LITERAL_STRING("SVGAbort"), this, true);
+      mDocument->RemoveEventListener(NS_LITERAL_STRING("SVGError"), this, true);
+      mDocument = nullptr;
+    }
   }
 
 private:
   nsCOMPtr<nsIDocument> mDocument;
   VectorImage* mImage; // Raw pointer to owner.
 };
 
 NS_IMPL_ISUPPORTS1(SVGLoadEventListener, nsIDOMEventListener)