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 174202 1552300c12e3f566acbadd084050d0c75a09959d
parent 174201 7832b912da928532ed9e4b0bc4aebb4e94e4eead
child 174203 a1cba1f33a49fa2a120228c2d2f40712d8501a9b
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)
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);
 }
 
 }
 }