Bug 1108449 - Add nullptr check in ImageHost and CompositableHost. r=nical
authorBoris Chiou <boris.chiou@gmail.com>
Sat, 20 Dec 2014 23:16:00 +0100
changeset 250771 6d29b59c3f11a8d682ea237cc7aa51ed1e424426
parent 250770 fd96c3cf0a2cbd4e2c4d076781520c645aa799a8
child 250772 40de0df2c4d168829045770ec7620bebc9604fb0
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1108449
milestone38.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 1108449 - Add nullptr check in ImageHost and CompositableHost. r=nical
gfx/layers/composite/CompositableHost.h
gfx/layers/composite/ImageHost.cpp
--- a/gfx/layers/composite/CompositableHost.h
+++ b/gfx/layers/composite/CompositableHost.h
@@ -275,22 +275,22 @@ protected:
 };
 
 class AutoLockCompositableHost MOZ_FINAL
 {
 public:
   explicit AutoLockCompositableHost(CompositableHost* aHost)
     : mHost(aHost)
   {
-    mSucceeded = mHost->Lock();
+    mSucceeded = (mHost && mHost->Lock());
   }
 
   ~AutoLockCompositableHost()
   {
-    if (mSucceeded) {
+    if (mSucceeded && mHost) {
       mHost->Unlock();
     }
   }
 
   bool Failed() const { return !mSucceeded; }
 
 private:
   RefPtr<CompositableHost> mHost;
--- a/gfx/layers/composite/ImageHost.cpp
+++ b/gfx/layers/composite/ImageHost.cpp
@@ -245,28 +245,33 @@ ImageHost::GetAsSurface()
 {
   return mFrontBuffer->GetAsSurface();
 }
 
 bool
 ImageHost::Lock()
 {
   MOZ_ASSERT(!mLocked);
+  if (!mFrontBuffer) {
+    return false;
+  }
   if (!mFrontBuffer->Lock()) {
     return false;
   }
   mLocked = true;
   return true;
 }
 
 void
 ImageHost::Unlock()
 {
   MOZ_ASSERT(mLocked);
-  mFrontBuffer->Unlock();
+  if (mFrontBuffer) {
+    mFrontBuffer->Unlock();
+  }
   mLocked = false;
 }
 
 IntSize
 ImageHost::GetImageSize() const
 {
   if (mHasPictureRect) {
     return IntSize(mPictureRect.width, mPictureRect.height);