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 323784 6d906f5908d1014d3eb6f5a38d2d00aaaa2cc45e
parent 323783 f77c4250f23a32162a7783608e2343800335f641
child 323785 3d7142a4f06d94aa5701e570faf90751aa3d7469
push id84219
push usercbook@mozilla.com
push dateTue, 22 Nov 2016 15:58:30 +0000
treeherdermozilla-inbound@6d906f5908d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1316539
milestone53.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 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());