Bug 1164513 - Add nullptr check r=milan
authorSotaro Ikeda <sikeda@mozilla.com>
Thu, 14 May 2015 12:09:18 -0700
changeset 243828 16767d529dfe97de1802d4a3becf6a815a3750f9
parent 243827 ec7cf8914e8e26b13c9672e0b9d629a583bf2994
child 243829 560058cbd35525dc52daebd2cdc27ea348b02adc
child 243833 f4041c4fd0fd98ca53f98ee270ea4df3baf44ced
push id28753
push userkwierso@gmail.com
push dateThu, 14 May 2015 22:33:43 +0000
treeherdermozilla-central@07e2e15703cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmilan
bugs1164513
milestone41.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 1164513 - Add nullptr check r=milan
gfx/layers/ipc/SharedBufferManagerParent.cpp
gfx/layers/opengl/GrallocTextureHost.cpp
--- a/gfx/layers/ipc/SharedBufferManagerParent.cpp
+++ b/gfx/layers/ipc/SharedBufferManagerParent.cpp
@@ -359,17 +359,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
@@ -226,16 +226,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);