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 176382 cf9032d586123389f5b45b9412683b0c76c4759e
parent 176381 00c79b18129972e9f012e296414d8b5cdb54fab2
child 176383 f5e8807d2a48ee3bed90ce655e0b93a4a3367a11
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical, sledru
bugs966543
milestone28.0
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
@@ -42,17 +42,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;
 }
@@ -85,19 +85,25 @@ MacIOSurfaceTextureSourceOGL::BindTextur
 gl::GLContext*
 MacIOSurfaceTextureSourceOGL::gl() const
 {
   return mCompositor ? mCompositor->gl() : nullptr;
 }
 
 gfx::SurfaceFormat
 MacIOSurfaceTextureHostOGL::GetFormat() const {
+  if (!mSurface) {
+    return gfx::FORMAT_UNKNOWN;
+  }
   return mSurface->HasAlpha() ? gfx::FORMAT_R8G8B8A8 : gfx::FORMAT_B8G8R8X8;
 }
 
 gfx::IntSize
 MacIOSurfaceTextureHostOGL::GetSize() const {
+  if (!mSurface) {
+    return gfx::IntSize();
+  }
   return gfx::IntSize(mSurface->GetDevicePixelWidth(),
                       mSurface->GetDevicePixelHeight());
 }
 
 }
 }