summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2004-12-03 18:12:08 +0000
committerBrian Paul <[email protected]>2004-12-03 18:12:08 +0000
commitcbc527cd17f587242944158319e32187458e1651 (patch)
treefdccf10ee69facfa94ab596b7aca046f5fed6e67
parent0fdb7ef8779adf6ae07c73bb0559651846fbe8c6 (diff)
mask color indexes against palette size, per the spec
-rw-r--r--src/mesa/main/texformat_tmp.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h
index d341c7864ae..275a84ef9e8 100644
--- a/src/mesa/main/texformat_tmp.h
+++ b/src/mesa/main/texformat_tmp.h
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.1
+ * Version: 6.3
*
* Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
*
@@ -1023,9 +1023,9 @@ static void FETCH(ci8)( const struct gl_texture_image *texImage,
GLint i, GLint j, GLint k, GLchan *texel )
{
const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
- const GLuint index = *src;
const struct gl_color_table *palette;
const GLchan *table;
+ GLuint index;
GET_CURRENT_CONTEXT(ctx);
if (ctx->Texture.SharedPalette) {
@@ -1039,6 +1039,9 @@ static void FETCH(ci8)( const struct gl_texture_image *texImage,
ASSERT(palette->Type != GL_FLOAT);
table = (const GLchan *) palette->Table;
+ /* Mask the index against size of palette to avoid going out of bounds */
+ index = (*src) & (palette->Size - 1);
+
switch (palette->Format) {
case GL_ALPHA:
texel[RCOMP] =