[1/3] wined3d: Fix crash in list remove if vertex shader creation fails.

Pauli Nieminen suokkos at gmail.com
Wed Dec 17 08:37:45 CST 2008


Also change CreatePixelShader to use same logic just in case there is memory leak.

Resending the patch with correct numbering for depending patches. Hopefully all
issues in previous patches are fixed.
---
 dlls/wined3d/device.c |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 6ded1a2..7bf56a1 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1888,14 +1888,14 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexShader(IWineD3DDevice *ifac
 
     hr = IWineD3DVertexShader_SetFunction(*ppVertexShader, pFunction);
 
+    list_add_head(&This->shaders, &object->baseShader.shader_list_entry);
+
     if (WINED3D_OK != hr) {
         FIXME("(%p) : Failed to set the function, returning WINED3DERR_INVALIDCALL\n", iface);
         IWineD3DVertexShader_Release(*ppVertexShader);
-        return WINED3DERR_INVALIDCALL;
     }
-    list_add_head(&This->shaders, &object->baseShader.shader_list_entry);
 
-    return WINED3D_OK;
+    return hr;
 }
 
 static HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface, CONST DWORD *pFunction, IWineD3DPixelShader **ppPixelShader, IUnknown *parent) {
@@ -1908,11 +1908,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface
     D3DCREATESHADEROBJECTINSTANCE(object, PixelShader)
     object->baseShader.shader_ins = IWineD3DPixelShaderImpl_shader_ins;
     hr = IWineD3DPixelShader_SetFunction(*ppPixelShader, pFunction);
-    if (WINED3D_OK == hr) {
-        TRACE("(%p) : Created Pixel shader %p\n", This, *ppPixelShader);
-        list_add_head(&This->shaders, &object->baseShader.shader_list_entry);
-    } else {
-        WARN("(%p) : Failed to create pixel shader\n", This);
+    list_add_head(&This->shaders, &object->baseShader.shader_list_entry);
+    if (WINED3D_OK != hr) {
+        FIXME("(%p) : Failed to create pixel shader\n", This);
+        IWineD3DPixelShader_Release(*ppPixelShader);
     }
 
     return hr;
-- 
1.5.6.3




More information about the wine-patches mailing list