Bug 1164513 - Add nullptr check. r=milan, a=jocheng
authorSotaro Ikeda <sikeda@mozilla.com>
Thu, 14 May 2015 12:09:18 -0700
changeset 238406 da5919916ba7ecbfc29296d5394aff907c244388
parent 238405 3e7681d6115138ebe6d7817e78ed8c5624c3284d
child 238407 fe3cb392cc58eff5072f61783be3b7acd38c5c0d
push id610
push userryanvm@gmail.com
push dateTue, 19 May 2015 01:50:15 +0000
treeherdermozilla-b2g37_v2_2@d50110422703 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmilan, jocheng
bugs1164513
milestone37.0
Bug 1164513 - Add nullptr check. r=milan, a=jocheng
gfx/layers/ipc/SharedBufferManagerParent.cpp
gfx/layers/opengl/GrallocTextureHost.cpp
--- a/gfx/layers/ipc/SharedBufferManagerParent.cpp
+++ b/gfx/layers/ipc/SharedBufferManagerParent.cpp
@@ -361,17 +361,21 @@ SharedBufferManagerParent::GetGraphicBuf
     return nullptr;
   }
 }
 
 android::sp<android::GraphicBuffer>
 SharedBufferManagerParent::GetGraphicBuffer(GrallocBufferRef aRef)
 {
   MonitorAutoLock lock(*sManagerMonitor.get());
-  return GetInstance(aRef.mOwner)->GetGraphicBuffer(aRef.mKey);
+  SharedBufferManagerParent* parent = GetInstance(aRef.mOwner);
+  if (!parent) {
+    return nullptr;
+  }
+  return parent->GetGraphicBuffer(aRef.mKey);
 }
 #endif
 
 IToplevelProtocol*
 SharedBufferManagerParent::CloneToplevel(const InfallibleTArray<ProtocolFdMapping>& aFds,
                                  base::ProcessHandle aPeerProcess,
                                  mozilla::ipc::ProtocolCloneContext* aCtx)
 {
--- a/gfx/layers/opengl/GrallocTextureHost.cpp
+++ b/gfx/layers/opengl/GrallocTextureHost.cpp
@@ -225,16 +225,19 @@ GrallocTextureHostOGL::GetRenderState()
   }
 
   return LayerRenderState();
 }
 
 TemporaryRef<gfx::DataSourceSurface>
 GrallocTextureHostOGL::GetAsSurface() {
   android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get();
+  if (!graphicBuffer) {
+    return nullptr;
+  }
   uint8_t* grallocData;
   graphicBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN, reinterpret_cast<void**>(&grallocData));
   RefPtr<gfx::DataSourceSurface> grallocTempSurf =
     gfx::Factory::CreateWrappingDataSourceSurface(grallocData,
                                                   graphicBuffer->getStride() * android::bytesPerPixel(graphicBuffer->getPixelFormat()),
                                                   GetSize(), GetFormat());
   RefPtr<gfx::DataSourceSurface> surf = CreateDataSourceSurfaceByCloning(grallocTempSurf);