Validate level exists for TexSubImage calls.
Before validating the texture format, verify that the texture level already
exists in glTexSubImage calls.
BUG=602737
Change-Id: I0d83c7d43c7b358abdb59583dc83265df70c13b5
Reviewed-on: https://chromium-review.googlesource.com/411361
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index 39a0c80..1d7b894 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -368,10 +368,16 @@
if (isSubImage)
{
+ GLenum textureFormat = texture->getFormat(target, level).asSized();
+ if (textureFormat == GL_NONE)
+ {
+ context->handleError(Error(GL_INVALID_OPERATION, "Texture level does not exist."));
+ return false;
+ }
+
if (format != GL_NONE)
{
- if (gl::GetSizedInternalFormat(format, type) !=
- texture->getFormat(target, level).asSized())
+ if (gl::GetSizedInternalFormat(format, type) != textureFormat)
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;