[PATCH] check for overflow of the textures areas.

Marcus Meissner marcus at jet.franken.de
Sun Jul 1 15:54:41 CDT 2007


---
 dlls/wined3d/device.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index ed6b6f9..039dcff 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -2886,6 +2886,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl
         Sampler -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
     }
 
+    if (Sampler >= sizeof(This->stateBlock->samplerState)/sizeof(This->stateBlock->samplerState[0]))
+	return E_FAIL;
+
     /**
     * SetSampler is designed to allow for more than the standard up to 8 textures
     *  and Geforce has stopped supporting more than 6 standard textures in openGL.
@@ -2932,6 +2935,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl
         Sampler -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
     }
 
+    if (Sampler >= sizeof(This->stateBlock->samplerState)/sizeof(This->stateBlock->samplerState[0]))
+	return E_FAIL;
+
     *Value = This->stateBlock->samplerState[Sampler][Type];
     TRACE("(%p) : Returning %#x\n", This, *Value);
 
@@ -4119,6 +4125,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl
         Stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
     }
 
+    if (Stage >= sizeof(This->stateBlock->textureDimensions)/sizeof(This->stateBlock->textureDimensions[0]))
+	return E_FAIL;
+
     oldTexture = This->updateStateBlock->textures[Stage];
 
     if(pTexture != NULL) {
@@ -4212,6 +4221,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl
         Stage -= (WINED3DVERTEXTEXTURESAMPLER0 - MAX_FRAGMENT_SAMPLERS);
     }
 
+    if (Stage >= sizeof(This->stateBlock->textures)/sizeof(This->stateBlock->textures[0]))
+	return E_FAIL;
+
     *ppTexture=This->stateBlock->textures[Stage];
     if (*ppTexture)
         IWineD3DBaseTexture_AddRef(*ppTexture);
-- 
1.4.3.4



More information about the wine-patches mailing list