Bug 809259: Properly handle allocation failures. r=kanru
authorChris Jones <jones.chris.g@gmail.com>
Tue, 27 Nov 2012 22:54:39 -0800
changeset 114335 1b3784a646a998872b166389bd74dd6466253d3a
parent 114334 126d3e10e2d4f38dd6affbc9746115ff77ad148c
child 114336 df92760bdce428a16cc78046437752dc176b08fc
push id23913
push useremorley@mozilla.com
push dateWed, 28 Nov 2012 17:11:31 +0000
treeherdermozilla-central@17c267a881cf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskanru
bugs809259
milestone20.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 809259: Properly handle allocation failures. r=kanru
dom/camera/GonkNativeWindow.cpp
--- a/dom/camera/GonkNativeWindow.cpp
+++ b/dom/camera/GonkNativeWindow.cpp
@@ -258,21 +258,25 @@ int GonkNativeWindow::dequeueBuffer(andr
     if (gbuf == NULL) {
         status_t error;
         SurfaceDescriptor buffer;
         ImageBridgeChild *ibc = ImageBridgeChild::GetSingleton();
         ibc->AllocSurfaceDescriptorGralloc(gfxIntSize(mDefaultWidth, mDefaultHeight),
                                            mPixelFormat,
                                            mUsage,
                                            &buffer);
+        // We can only use a gralloc buffer here.  If we didn't get
+        // one back, something went wrong.
+        if (SurfaceDescriptor::TSurfaceDescriptorGralloc != buffer.type()) {
+            MOZ_ASSERT(SurfaceDescriptor::T__None == buffer.type());
+            CNW_LOGE("dequeueBuffer: failed to alloc gralloc buffer");
+            return -ENOMEM;
+        }
         sp<GraphicBuffer> graphicBuffer =
           GrallocBufferActor::GetFrom(buffer.get_SurfaceDescriptorGralloc());
-        if (!graphicBuffer.get()) {
-            return -ENOMEM;
-        }
         error = graphicBuffer->initCheck();
         if (error != NO_ERROR) {
             CNW_LOGE("dequeueBuffer: createGraphicBuffer failed with error %d",error);
             return error;
         }
         mSlots[buf].mGraphicBuffer = graphicBuffer;
         mSlots[buf].mSurfaceDescriptor = buffer;
         mSlots[buf].mSurfaceDescriptor.get_SurfaceDescriptorGralloc().external() = true;