Permalink
Browse files

Bug 827225 - Avoid JS_GetArrayBufferViewType until safe to call. r=bz

--HG--
extra : rebase_source : 5ac40b7fc9567cc02ab2f2167f756348f1a44fd0
  • Loading branch information...
1 parent 932c3b3 commit cc4abfb4ff5542f27f48985ec337780543b93d3e @hotsphink hotsphink committed Jan 7, 2013
Showing with 3 additions and 3 deletions.
  1. +3 −3 content/canvas/src/WebGLContextGL.cpp
@@ -3166,9 +3166,6 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
WebGLsizei framebufferWidth = framebufferRect ? framebufferRect->Width() : 0;
WebGLsizei framebufferHeight = framebufferRect ? framebufferRect->Height() : 0;
- uint32_t dataByteLen = JS_GetTypedArrayByteLength(pixels->Obj());
- int dataType = JS_GetArrayBufferViewType(pixels->Obj());
-
uint32_t channels = 0;
// Check the format param
@@ -3205,6 +3202,8 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
return ErrorInvalidEnum("readPixels: Bad type");
}
+ int dataType = JS_GetArrayBufferViewType(pixels->Obj());
+
// Check the pixels param type
if (dataType != requiredDataType)
return ErrorInvalidOperation("readPixels: Mismatched type/pixels types");
@@ -3221,6 +3220,7 @@ WebGLContext::ReadPixels(WebGLint x, WebGLint y, WebGLsizei width,
if (!checked_neededByteLength.isValid())
return ErrorInvalidOperation("readPixels: integer overflow computing the needed buffer size");
+ uint32_t dataByteLen = JS_GetTypedArrayByteLength(pixels->Obj());
if (checked_neededByteLength.value() > dataByteLen)
return ErrorInvalidOperation("readPixels: buffer too small");

0 comments on commit cc4abfb

Please sign in to comment.