WINED3D: Don't call glCompressedTexImage2DARB without allocatedMemory

H. Verbeet hverbeet at gmail.com
Mon Mar 6 12:27:53 CST 2006


IWineD3DSurfaceImpl_LoadTexture can get called for surfaces/textures
that have a NULL allocatedMemory. It looks like it's not defined what
glCompressedTexImage2DARB should do when called with NULL data. I
suspect it simply does nothing with ATI OpenGL libraries, but with
nVidia libraries it causes a NULL pointer dereferences somewhere in
memcpy.

Changelog:
  - Don't call glCompressedTexImage2DARB if we haven't got
allocatedMemory (yet).
  - Fix a small typo.
-------------- next part --------------
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index a4d9770..f8e6abf 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1029,7 +1029,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadT
         This->resource.format == WINED3DFMT_DXT3 ||
         This->resource.format == WINED3DFMT_DXT4 ||
         This->resource.format == WINED3DFMT_DXT5) {
-        if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
+        if (!GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) {
+            FIXME("Using DXT1/3/5 without advertized support\n");
+        } else if (This->resource.allocatedMemory) {
             TRACE("Calling glCompressedTexImage2D %x i=%d, intfmt=%x, w=%d, h=%d,0=%d, sz=%d, Mem=%p\n",
                   This->glDescription.target,
                   This->glDescription.level,
@@ -1050,7 +1052,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadT
                                                   0,
                                                   This->resource.size,
                                                   This->resource.allocatedMemory);
-            checkGLcall("glCommpressedTexTexImage2D");
+            checkGLcall("glCommpressedTexImage2D");
 
             LEAVE_GL();
 
@@ -1058,9 +1060,6 @@ HRESULT WINAPI IWineD3DSurfaceImpl_LoadT
                 HeapFree(GetProcessHeap(), 0, This->resource.allocatedMemory);
                 This->resource.allocatedMemory = NULL;
             }
-
-        } else {
-            FIXME("Using DXT1/3/5 without advertized support\n");
         }
     } else {
 



More information about the wine-patches mailing list