Bug 966543 - Null check mSurface in MacIOSurfaceTextureHostOGL. r=nical, a=sledru
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 18 Feb 2014 09:32:49 +1300
changeset 182998 79b269235c03d1915f3a7ad1b71ba6324bdf27b6
parent 182997 e245c793a38efbb5145b4e8e7bbf118a50cb11b1
child 182999 b8e64e9f9e66b073d6a5e8548e39aadcc01fc24a
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, sledru
bugs966543
milestone29.0a2
Bug 966543 - Null check mSurface in MacIOSurfaceTextureHostOGL. r=nical, a=sledru
gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
--- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
+++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
@@ -41,17 +41,17 @@ MacIOSurfaceTextureHostOGL::MacIOSurface
   mSurface = MacIOSurface::LookupSurface(aDescriptor.surface(),
                                          aDescriptor.scaleFactor(),
                                          aDescriptor.hasAlpha());
 }
 
 bool
 MacIOSurfaceTextureHostOGL::Lock()
 {
-  if (!mCompositor) {
+  if (!mCompositor || !mSurface) {
     return false;
   }
 
   if (!mTextureSource) {
     mTextureSource = new MacIOSurfaceTextureSourceOGL(mCompositor, mSurface);
   }
   return true;
 }
@@ -90,19 +90,25 @@ MacIOSurfaceTextureSourceOGL::SetComposi
 gl::GLContext*
 MacIOSurfaceTextureSourceOGL::gl() const
 {
   return mCompositor ? mCompositor->gl() : nullptr;
 }
 
 gfx::SurfaceFormat
 MacIOSurfaceTextureHostOGL::GetFormat() const {
+  if (!mSurface) {
+    return gfx::SurfaceFormat::UNKNOWN;
+  }
   return mSurface->HasAlpha() ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8X8;
 }
 
 gfx::IntSize
 MacIOSurfaceTextureHostOGL::GetSize() const {
+  if (!mSurface) {
+    return gfx::IntSize();
+  }
   return gfx::IntSize(mSurface->GetDevicePixelWidth(),
                       mSurface->GetDevicePixelHeight());
 }
 
 }
 }