Bug 809259: Properly handle allocation failures. r=kanru

This commit is contained in:
Chris Jones 2012-11-27 22:54:39 -08:00
Родитель b302b0b395
Коммит 57c48cf12d
1 изменённых файлов: 7 добавлений и 3 удалений

Просмотреть файл

@ -263,11 +263,15 @@ int GonkNativeWindow::dequeueBuffer(android_native_buffer_t** buffer)
mPixelFormat, mPixelFormat,
mUsage, mUsage,
&buffer); &buffer);
sp<GraphicBuffer> graphicBuffer = // We can only use a gralloc buffer here. If we didn't get
GrallocBufferActor::GetFrom(buffer.get_SurfaceDescriptorGralloc()); // one back, something went wrong.
if (!graphicBuffer.get()) { if (SurfaceDescriptor::TSurfaceDescriptorGralloc != buffer.type()) {
MOZ_ASSERT(SurfaceDescriptor::T__None == buffer.type());
CNW_LOGE("dequeueBuffer: failed to alloc gralloc buffer");
return -ENOMEM; return -ENOMEM;
} }
sp<GraphicBuffer> graphicBuffer =
GrallocBufferActor::GetFrom(buffer.get_SurfaceDescriptorGralloc());
error = graphicBuffer->initCheck(); error = graphicBuffer->initCheck();
if (error != NO_ERROR) { if (error != NO_ERROR) {
CNW_LOGE("dequeueBuffer: createGraphicBuffer failed with error %d",error); CNW_LOGE("dequeueBuffer: createGraphicBuffer failed with error %d",error);