Adds missing parameter checks to texture functions

TRAC #18802 Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/trunk@900 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent f1286449
#define MAJOR_VERSION 1 #define MAJOR_VERSION 1
#define MINOR_VERSION 0 #define MINOR_VERSION 0
#define BUILD_VERSION 0 #define BUILD_VERSION 0
#define BUILD_REVISION 899 #define BUILD_REVISION 900
#define STRINGIFY(x) #x #define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x) #define MACRO_STRINGIFY(x) STRINGIFY(x)
......
...@@ -1042,6 +1042,12 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs ...@@ -1042,6 +1042,12 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
if (xoffset + width > texture->getWidth(level) ||
yoffset + height > texture->getHeight(level))
{
return error(GL_INVALID_VALUE);
}
texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data); texture->subImageCompressed(level, xoffset, yoffset, width, height, format, imageSize, data);
} }
else if (gl::IsCubemapTextureTarget(target)) else if (gl::IsCubemapTextureTarget(target))
...@@ -1064,6 +1070,12 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs ...@@ -1064,6 +1070,12 @@ void __stdcall glCompressedTexSubImage2D(GLenum target, GLint level, GLint xoffs
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
if (xoffset + width > texture->getWidth(level) ||
yoffset + height > texture->getHeight(level))
{
return error(GL_INVALID_VALUE);
}
texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data); texture->subImageCompressed(target, level, xoffset, yoffset, width, height, format, imageSize, data);
} }
else else
...@@ -1330,6 +1342,12 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL ...@@ -1330,6 +1342,12 @@ void __stdcall glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GL
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
if (xoffset + width > texture->getWidth(level) ||
yoffset + height > texture->getHeight(level))
{
return error(GL_INVALID_VALUE);
}
GLenum textureFormat = texture->getInternalFormat(); GLenum textureFormat = texture->getInternalFormat();
// [OpenGL ES 2.0.24] table 3.9 // [OpenGL ES 2.0.24] table 3.9
...@@ -5042,6 +5060,26 @@ void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalf ...@@ -5042,6 +5060,26 @@ void __stdcall glTexStorage2DEXT(GLenum target, GLsizei levels, GLenum internalf
if (context) if (context)
{ {
switch (target)
{
case GL_TEXTURE_2D:
if (width > context->getMaximumTextureDimension() ||
height > context->getMaximumTextureDimension())
{
return error(GL_INVALID_VALUE);
}
break;
case GL_TEXTURE_CUBE_MAP:
if (width > context->getMaximumCubeTextureDimension() ||
height > context->getMaximumCubeTextureDimension())
{
return error(GL_INVALID_VALUE);
}
break;
default:
return error(GL_INVALID_ENUM);
}
if (levels != 1 && !context->supportsNonPower2Texture()) if (levels != 1 && !context->supportsNonPower2Texture())
{ {
if (!gl::isPow2(width) || !gl::isPow2(height)) if (!gl::isPow2(width) || !gl::isPow2(height))
...@@ -5212,6 +5250,12 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -5212,6 +5250,12 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
if (xoffset + width > texture->getWidth(level) ||
yoffset + height > texture->getHeight(level))
{
return error(GL_INVALID_VALUE);
}
texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels); texture->subImage(level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
} }
else if (gl::IsCubemapTextureTarget(target)) else if (gl::IsCubemapTextureTarget(target))
...@@ -5223,6 +5267,22 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint ...@@ -5223,6 +5267,22 @@ void __stdcall glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint
return error(GL_INVALID_OPERATION); return error(GL_INVALID_OPERATION);
} }
if (texture->isCompressed())
{
return error(GL_INVALID_OPERATION);
}
if (format != texture->getInternalFormat())
{
return error(GL_INVALID_OPERATION);
}
if (xoffset + width > texture->getWidth(level) ||
yoffset + height > texture->getHeight(level))
{
return error(GL_INVALID_VALUE);
}
texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels); texture->subImage(target, level, xoffset, yoffset, width, height, format, type, context->getUnpackAlignment(), pixels);
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment