From: Brian Paul Date: Tue, 4 Dec 2001 23:45:31 +0000 (+0000) Subject: fixed potential array overwrite problem X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=aecfb51c304a6d71810ba5ae6ab9c4e344b816a9;p=mesa.git fixed potential array overwrite problem --- diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index b94dbf0e1a3..b6fe7b2123a 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -1,8 +1,8 @@ -/* $Id: pixel.c,v 1.31 2001/09/18 16:16:21 kschultz Exp $ */ +/* $Id: pixel.c,v 1.32 2001/12/04 23:45:31 brianp Exp $ */ /* * Mesa 3-D graphics library - * Version: 3.5 + * Version: 4.1 * * Copyright (C) 1999-2001 Brian Paul All Rights Reserved. * @@ -258,15 +258,7 @@ _mesa_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values ) if (map>=GL_PIXEL_MAP_S_TO_S && map<=GL_PIXEL_MAP_I_TO_A) { /* test that mapsize is a power of two */ - GLuint p; - GLboolean ok = GL_FALSE; - for (p=1; p<=MAX_PIXEL_MAP_TABLE; p=p<<1) { - if ( (p&mapsize) == p ) { - ok = GL_TRUE; - break; - } - } - if (!ok) { + if (_mesa_bitcount((GLuint) mapsize) != 1) { _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" ); return; } @@ -353,15 +345,16 @@ _mesa_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values ) void _mesa_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values ) { + const GLint n = MIN2(mapsize, MAX_PIXEL_MAP_TABLE); GLfloat fvalues[MAX_PIXEL_MAP_TABLE]; GLint i; if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) { - for (i=0;i