Bug 921215 - Handle being passed NULL ptr for either surface or gl to SharedSurface_IOSurface::Create by returning NULL. r=mattwoodrow
authorDan Glastonbury <dglastonbury@mozilla.com>
Tue, 03 Dec 2013 13:11:27 +1000
changeset 158518 1552300c12e3
parent 158517 7832b912da92
child 158519 a1cba1f33a49
push id37012
push userryanvm@gmail.com
push dateTue, 03 Dec 2013 13:52:42 +0000
treeherdermozilla-inbound@efc30ce15377 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs921215
milestone28.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 921215 - Handle being passed NULL ptr for either surface or gl to SharedSurface_IOSurface::Create by returning NULL. r=mattwoodrow
gfx/gl/SharedSurfaceIO.cpp
--- a/gfx/gl/SharedSurfaceIO.cpp
+++ b/gfx/gl/SharedSurfaceIO.cpp
@@ -13,16 +13,19 @@
 namespace mozilla {
 namespace gl {
 
 using namespace gfx;
 
 /* static */ SharedSurface_IOSurface*
 SharedSurface_IOSurface::Create(MacIOSurface* surface, GLContext *gl, bool hasAlpha)
 {
+    MOZ_ASSERT(surface);
+    MOZ_ASSERT(gl);
+
     gfxIntSize size(surface->GetWidth(), surface->GetHeight());
     return new SharedSurface_IOSurface(surface, gl, size, hasAlpha);
 }
 
 void
 SharedSurface_IOSurface::Fence()
 {
     mGL->MakeCurrent();
@@ -94,13 +97,18 @@ SharedSurface_IOSurface::~SharedSurface_
 
 SharedSurface*
 SurfaceFactory_IOSurface::CreateShared(const gfxIntSize& size)
 {
     bool hasAlpha = mReadCaps.alpha;
     RefPtr<MacIOSurface> surf =
         MacIOSurface::CreateIOSurface(size.width, size.height, 1.0, hasAlpha);
 
+    if (!surf) {
+        NS_WARNING("Failed to create MacIOSurface.");
+        return nullptr;
+    }
+
     return SharedSurface_IOSurface::Create(surf, mGL, hasAlpha);
 }
 
 }
 }