diff options
author | Brian Paul <[email protected]> | 2010-02-03 12:31:27 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2010-02-03 15:48:42 -0700 |
commit | d82c37134457263715b8c571827df58ea6789593 (patch) | |
tree | 43ca01e3c452e72510af3e44379cdf51f30f6df9 /src/mesa/main/get.c | |
parent | a06575aed66b818253bc79dcca3d6e19c92e4bba (diff) |
mesa: add error check for querying invalid texture matrix
Diffstat (limited to 'src/mesa/main/get.c')
-rw-r--r-- | src/mesa/main/get.c | 36 |
1 files changed, 32 insertions, 4 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]); |