[PATCH] handle out of array bounds state

Marcus Meissner marcus at jet.franken.de
Wed Apr 16 15:54:28 CDT 2008


Hi,

Coverity spotted CID 694, array index overflow.
Since we print a FIXME already, just handle the
good "state" in an else branch.

Ciao, Marcus
---
 dlls/wined3d/basetexture.c |   19 ++++++++++---------
 1 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/dlls/wined3d/basetexture.c b/dlls/wined3d/basetexture.c
index 000c2f2..1f14a20 100644
--- a/dlls/wined3d/basetexture.c
+++ b/dlls/wined3d/basetexture.c
@@ -435,16 +435,17 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
         state = samplerStates[WINED3DSAMP_MAGFILTER];
         if (state < WINED3DTEXF_NONE || state > WINED3DTEXF_ANISOTROPIC) {
             FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
+        } else {
+            glValue = (*This->baseTexture.magLookup)[state - WINED3DTEXF_NONE];
+            TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
+            glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
+            /* We need to reset the Anisotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentation to see how it should be switched off. */
+            if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && WINED3DTEXF_ANISOTROPIC == state &&
+                textureDimensions != GL_TEXTURE_RECTANGLE_ARB) {
+                glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]);
+            }
+            This->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = state;
         }
-        glValue = (*This->baseTexture.magLookup)[state - WINED3DTEXF_NONE];
-        TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
-        glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
-        /* We need to reset the Anisotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentation to see how it should be switched off. */
-        if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC) && WINED3DTEXF_ANISOTROPIC == state &&
-            textureDimensions != GL_TEXTURE_RECTANGLE_ARB) {
-            glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, samplerStates[WINED3DSAMP_MAXANISOTROPY]);
-        }
-        This->baseTexture.states[WINED3DTEXSTA_MAGFILTER] = state;
     }
 
     if(textureDimensions != GL_TEXTURE_RECTANGLE_ARB &&
-- 
1.5.2.4



More information about the wine-patches mailing list