Bug 1316539 - Add null pixel check in TexSubImage. r=jgilbert
☠☠ backed out by 163297a7dce3 ☠ ☠
authorChih-Yi Leu <cleu@mozilla.com>
Mon, 21 Nov 2016 20:28:00 +0100
changeset 323850 6d906f5908d1014d3eb6f5a38d2d00aaaa2cc45e
parent 323849 f77c4250f23a32162a7783608e2343800335f641
child 323851 3d7142a4f06d94aa5701e570faf90751aa3d7469
push id21
push usermaklebus@msu.edu
push dateThu, 01 Dec 2016 06:22:08 +0000
reviewersjgilbert
bugs1316539
milestone53.0a1
Bug 1316539 - Add null pixel check in TexSubImage. r=jgilbert
dom/canvas/WebGLContext.h
dom/canvas/WebGLTextureUpload.cpp
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -205,16 +205,18 @@ struct TexImageSource
 
     const WebGLsizeiptr* mPboOffset;
 
     const dom::ImageData* mImageData;
 
     const dom::Element* mDomElem;
     ErrorResult* mOut_error;
 
+    bool IsNull() const { return (!mView && !mImageData && !mDomElem); }
+
 protected:
     TexImageSource() {
         memset(this, 0, sizeof(*this));
     }
 };
 
 ////
 
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -440,16 +440,20 @@ WebGLTexture::TexImage(const char* funcN
 }
 
 void
 WebGLTexture::TexSubImage(const char* funcName, TexImageTarget target, GLint level,
                           GLint xOffset, GLint yOffset, GLint zOffset, GLsizei width,
                           GLsizei height, GLsizei depth,
                           const webgl::PackingInfo& pi, const TexImageSource& src)
 {
+    if (src.IsNull()) {
+        mContext->ErrorInvalidValue("%s: Pixels must be non-null.", funcName);
+        return;
+    }
     const GLint border = 0;
     dom::RootedTypedArray<dom::Uint8ClampedArray> scopedArr(dom::RootingCx());
     const auto blob = ValidateTexOrSubImage(mContext, funcName, target, width, height,
                                             depth, border, pi, src, &scopedArr);
     if (!blob)
         return;
 
     TexSubImage(funcName, target, level, xOffset, yOffset, zOffset, pi, blob.get());