Bug 1445980 - TexStorage should validate both highest and lowest levels. - r=kvark draft
authorJeff Gilbert <jgilbert@mozilla.com>
Mon, 26 Mar 2018 18:39:46 -0700
changeset 772864 c305df2cd7d531d9926ea4a3c76fadaa5e40370b
parent 772787 de32269720d056972b85f4eec5f0a8286de6e3af
push id104069
push userbmo:jgilbert@mozilla.com
push dateTue, 27 Mar 2018 02:27:27 +0000
reviewerskvark
bugs1445980
milestone61.0a1
Bug 1445980 - TexStorage should validate both highest and lowest levels. - r=kvark MozReview-Commit-ID: 3MtNEAtuadY
dom/canvas/WebGLTextureUpload.cpp
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -1102,42 +1102,42 @@ WebGLTexture::TexStorage(const char* fun
 
     if (!width || !height || !depth) {
         mContext->ErrorInvalidValue("%s: Dimensions must be non-zero.", funcName);
         return;
     }
 
     const TexImageTarget testTarget = IsCubeMap() ? LOCAL_GL_TEXTURE_CUBE_MAP_POSITIVE_X
                                                   : target.get();
-    const GLint testLevel = 0;
-
-    WebGLTexture::ImageInfo* testImageInfo;
-    if (!ValidateTexImageSpecification(funcName, testTarget, testLevel, width, height,
-                                       depth, &testImageInfo))
+    WebGLTexture::ImageInfo* baseImageInfo;
+    WebGLTexture::ImageInfo* lastImageInfo;
+    if (!ValidateTexImageSpecification(funcName, testTarget, 0, width, height, depth,
+                                       &baseImageInfo) ||
+        !ValidateTexImageSpecification(funcName, testTarget, levels-1, 1, 1, 1,
+                                       &lastImageInfo))
     {
         return;
     }
-    MOZ_ASSERT(testImageInfo);
-    mozilla::Unused << testImageInfo;
+    MOZ_ALWAYS_TRUE(baseImageInfo);
+    MOZ_ALWAYS_TRUE(lastImageInfo);
 
     auto dstUsage = mContext->mFormatUsage->GetSizedTexUsage(sizedFormat);
     if (!dstUsage) {
         mContext->ErrorInvalidEnum("%s: Invalid internalformat: 0x%04x", funcName,
                                    sizedFormat);
         return;
     }
     auto dstFormat = dstUsage->format;
 
     if (!ValidateTargetForFormat(funcName, mContext, testTarget, dstFormat))
         return;
 
     if (dstFormat->compression) {
-        if (!ValidateCompressedTexImageRestrictions(funcName, mContext, testTarget,
-                                                    testLevel, dstFormat, width, height,
-                                                    depth))
+        if (!ValidateCompressedTexImageRestrictions(funcName, mContext, testTarget, 0,
+                                                    dstFormat, width, height, depth))
         {
             return;
         }
     }
 
     ////////////////////////////////////
 
     const auto lastLevel = levels - 1;