From 37a26121ee92c0892be7d89361dc93da626322a6 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Thu, 22 Nov 2012 13:53:11 -0500 Subject: [PATCH] Bug 814407 - check for null buffer data in readpixels (should never happen, but apparently does) - r=jgilbert --- content/canvas/src/WebGLContextGL.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/content/canvas/src/WebGLContextGL.cpp b/content/canvas/src/WebGLContextGL.cpp index 9111f0b9a72a..95abdb3b2b90 100644 --- a/content/canvas/src/WebGLContextGL.cpp +++ b/content/canvas/src/WebGLContextGL.cpp @@ -3156,7 +3156,6 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width, WebGLsizei framebufferWidth = framebufferRect ? framebufferRect->Width() : 0; WebGLsizei framebufferHeight = framebufferRect ? framebufferRect->Height() : 0; - void* data = pixels->Data(); uint32_t dataByteLen = JS_GetTypedArrayByteLength(pixels->Obj()); int dataType = JS_GetTypedArrayType(pixels->Obj()); @@ -3215,6 +3214,12 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width, if (checked_neededByteLength.value() > dataByteLen) return ErrorInvalidOperation("readPixels: buffer too small"); + void* data = pixels->Data(); + if (!data) { + ErrorOutOfMemory("readPixels: buffer storage is null. Did we run out of memory?"); + return rv.Throw(NS_ERROR_OUT_OF_MEMORY); + } + // Check the format and type params to assure they are an acceptable pair (as per spec) switch (format) { case LOCAL_GL_RGBA: {