summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2010-02-03 12:31:27 -0700
committerBrian Paul <[email protected]>2010-02-03 15:48:42 -0700
commitd82c37134457263715b8c571827df58ea6789593 (patch)
tree43ca01e3c452e72510af3e44379cdf51f30f6df9 /src
parenta06575aed66b818253bc79dcca3d6e19c92e4bba (diff)
mesa: add error check for querying invalid texture matrix
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/get.c36
-rw-r--r--src/mesa/main/get_gen.py10
2 files changed, 41 insertions, 5 deletions
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 22cf75f79de..fba5479be4e 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -922,7 +922,14 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params )
break;
case GL_TEXTURE_MATRIX:
{
- const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
+ const GLfloat *matrix;
+ const GLuint unit = ctx->Texture.CurrentUnit;
+ if (unit >= ctx->Const.MaxTextureCoordUnits) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGet(texture matrix %u)",
+ unit);
+ return;
+ }
+ matrix = ctx->TextureMatrixStack[unit].Top->m;
params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
params[1] = FLOAT_TO_BOOLEAN(matrix[1]);
params[2] = FLOAT_TO_BOOLEAN(matrix[2]);
@@ -2766,7 +2773,14 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params )
break;
case GL_TEXTURE_MATRIX:
{
- const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
+ const GLfloat *matrix;
+ const GLuint unit = ctx->Texture.CurrentUnit;
+ if (unit >= ctx->Const.MaxTextureCoordUnits) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGet(texture matrix %u)",
+ unit);
+ return;
+ }
+ matrix = ctx->TextureMatrixStack[unit].Top->m;
params[0] = matrix[0];
params[1] = matrix[1];
params[2] = matrix[2];
@@ -4610,7 +4624,14 @@ _mesa_GetIntegerv( GLenum pname, GLint *params )
break;
case GL_TEXTURE_MATRIX:
{
- const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
+ const GLfloat *matrix;
+ const GLuint unit = ctx->Texture.CurrentUnit;
+ if (unit >= ctx->Const.MaxTextureCoordUnits) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGet(texture matrix %u)",
+ unit);
+ return;
+ }
+ matrix = ctx->TextureMatrixStack[unit].Top->m;
params[0] = IROUND(matrix[0]);
params[1] = IROUND(matrix[1]);
params[2] = IROUND(matrix[2]);
@@ -6455,7 +6476,14 @@ _mesa_GetInteger64v( GLenum pname, GLint64 *params )
break;
case GL_TEXTURE_MATRIX:
{
- const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
+ const GLfloat *matrix;
+ const GLuint unit = ctx->Texture.CurrentUnit;
+ if (unit >= ctx->Const.MaxTextureCoordUnits) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGet(texture matrix %u)",
+ unit);
+ return;
+ }
+ matrix = ctx->TextureMatrixStack[unit].Top->m;
params[0] = IROUND64(matrix[0]);
params[1] = IROUND64(matrix[1]);
params[2] = IROUND64(matrix[2]);
diff --git a/src/mesa/main/get_gen.py b/src/mesa/main/get_gen.py
index b0beb592075..7bd87bb0d7b 100644
--- a/src/mesa/main/get_gen.py
+++ b/src/mesa/main/get_gen.py
@@ -457,7 +457,15 @@ StateVars = [
"matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
"matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
"matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
- "const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;", None ),
+ """const GLfloat *matrix;
+ const GLuint unit = ctx->Texture.CurrentUnit;
+ if (unit >= ctx->Const.MaxTextureCoordUnits) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGet(texture matrix %u)",
+ unit);
+ return;
+ }
+ matrix = ctx->TextureMatrixStack[unit].Top->m;""",
+ None ),
( "GL_TEXTURE_STACK_DEPTH", GLint,
["ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1"], "", None ),
( "GL_UNPACK_ALIGNMENT", GLint, ["ctx->Unpack.Alignment"], "", None ),