Bug 1186264 - Add error check to GrallocTextureHostOGL::GetAsSurface() r=nical
authorSotaro Ikeda <sikeda@mozilla.com>
Thu, 30 Jul 2015 14:43:59 -0700
changeset 287223 eafffe750ebb430eb48caaba500a0fa81bb7ab36
parent 287222 54e85cce2cadab90168e9ac93e4e4dfeb53667dd
child 287224 104b0bbd714fbd14dd41428b15ad20da7123ab23
push id5067
push userraliiev@mozilla.com
push dateMon, 21 Sep 2015 14:04:52 +0000
treeherdermozilla-beta@14221ffe5b2f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1186264
milestone42.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 1186264 - Add error check to GrallocTextureHostOGL::GetAsSurface() r=nical
gfx/layers/opengl/GrallocTextureHost.cpp
--- a/gfx/layers/opengl/GrallocTextureHost.cpp
+++ b/gfx/layers/opengl/GrallocTextureHost.cpp
@@ -233,21 +233,28 @@ GrallocTextureHostOGL::GetRenderState()
 
 already_AddRefed<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));
+  int32_t rv = graphicBuffer->lock(GRALLOC_USAGE_SW_READ_OFTEN, reinterpret_cast<void**>(&grallocData));
+  if (rv) {
+    return nullptr;
+  }
   RefPtr<gfx::DataSourceSurface> grallocTempSurf =
     gfx::Factory::CreateWrappingDataSourceSurface(grallocData,
                                                   graphicBuffer->getStride() * android::bytesPerPixel(graphicBuffer->getPixelFormat()),
                                                   GetSize(), GetFormat());
+  if (!grallocTempSurf) {
+    graphicBuffer->unlock();
+    return nullptr;
+  }
   RefPtr<gfx::DataSourceSurface> surf = CreateDataSourceSurfaceByCloning(grallocTempSurf);
 
   graphicBuffer->unlock();
 
   return surf.forget();
 }
 
 void