Bug 1445980 - TexStorage should validate both highest and lowest levels. - r=kvark
MozReview-Commit-ID: 3MtNEAtuadY
--- 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;