Re: [PATCH 2/5] dxgi: Free the wined3d object when device creation fails (Valgrind).
On 27 August 2014 18:40, Matteo Bruni <mbruni(a)codeweavers.com> wrote:
--- dlls/dxgi/device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index 837c57f..0f3ae7d 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -350,7 +350,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l IWineDXGIDeviceParent *dxgi_device_parent; IWineDXGIAdapter *wine_adapter; UINT adapter_ordinal; - struct wined3d *wined3d; + struct wined3d *wined3d = NULL; void *layer_base; HRESULT hr; WINED3DCAPS caps; @@ -430,6 +430,12 @@ fail: wined3d_device_decref(device->wined3d_device); LeaveCriticalSection(&dxgi_cs); } + else if (wined3d) + { + EnterCriticalSection(&dxgi_cs); + wined3d_decref(wined3d); + LeaveCriticalSection(&dxgi_cs); + }
I don't think this works as intended. For example, if IDXGIAdapter_QueryInterface() fails, you'd call wined3d_decref() twice. There's also a wined3d_decref() after wined3d_device_create(), although it's indeed missing for IWineDXGIDevice_QueryInterface() and wined3d_get_device_caps().
2014-08-27 19:22 GMT+02:00 Henri Verbeet <hverbeet(a)gmail.com>:
On 27 August 2014 18:40, Matteo Bruni <mbruni(a)codeweavers.com> wrote:
--- dlls/dxgi/device.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/dlls/dxgi/device.c b/dlls/dxgi/device.c index 837c57f..0f3ae7d 100644 --- a/dlls/dxgi/device.c +++ b/dlls/dxgi/device.c @@ -350,7 +350,7 @@ HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *l IWineDXGIDeviceParent *dxgi_device_parent; IWineDXGIAdapter *wine_adapter; UINT adapter_ordinal; - struct wined3d *wined3d; + struct wined3d *wined3d = NULL; void *layer_base; HRESULT hr; WINED3DCAPS caps; @@ -430,6 +430,12 @@ fail: wined3d_device_decref(device->wined3d_device); LeaveCriticalSection(&dxgi_cs); } + else if (wined3d) + { + EnterCriticalSection(&dxgi_cs); + wined3d_decref(wined3d); + LeaveCriticalSection(&dxgi_cs); + }
I don't think this works as intended. For example, if IDXGIAdapter_QueryInterface() fails, you'd call wined3d_decref() twice.
Uh, indeed. I'll fix that up.
There's also a wined3d_decref() after wined3d_device_create(),
That too.
although it's indeed missing for IWineDXGIDevice_QueryInterface() and wined3d_get_device_caps().
participants (2)
-
Henri Verbeet -
Matteo Bruni