From 29d4ab1316f6b40241b07ac9bfeb075ce0277205 Mon Sep 17 00:00:00 2001 From: Christian Costa Date: Tue, 23 Dec 2008 11:57:32 +0100 Subject: [PATCH] d3dxof: Release properly all allocated resources. --- dlls/d3dxof/d3dxof.c | 16 +++++++++++++--- dlls/d3dxof/d3dxof_private.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/dlls/d3dxof/d3dxof.c b/dlls/d3dxof/d3dxof.c index 6004ed6833a..0dc93afaca8 100644 --- a/dlls/d3dxof/d3dxof.c +++ b/dlls/d3dxof/d3dxof.c @@ -1538,7 +1538,14 @@ static ULONG WINAPI IDirectXFileDataImpl_Release(IDirectXFileData* iface) TRACE("(%p/%p): ReleaseRef to %d\n", iface, This, ref); if (!ref) + { + if (!This->level) + { + HeapFree(GetProcessHeap(), 0, This->pdata); + HeapFree(GetProcessHeap(), 0, This->pstrings); + } HeapFree(GetProcessHeap(), 0, This); + } return ref; } @@ -1902,7 +1909,10 @@ static ULONG WINAPI IDirectXFileEnumObjectImpl_Release(IDirectXFileEnumObject* i if (!ref) { - CloseHandle(This->hFile); + if (This->source == DXFILELOAD_FROMFILE) + HeapFree(GetProcessHeap(), 0, This->buf.buffer); + if (This->hFile != INVALID_HANDLE_VALUE) + CloseHandle(This->hFile); HeapFree(GetProcessHeap(), 0, This); } @@ -2258,7 +2268,7 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileE hr = DXFILEERR_BADALLOC; goto error; } - This->buf.cur_pdata = This->buf.pdata = pdata; + This->buf.cur_pdata = This->buf.pdata = object->pdata = pdata; pstrings = HeapAlloc(GetProcessHeap(), 0, MAX_STRINGS_BUFFER); if (!pstrings) @@ -2267,7 +2277,7 @@ static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileE hr = DXFILEERR_BADALLOC; goto error; } - This->buf.cur_pstrings = This->buf.pstrings = pstrings; + This->buf.cur_pstrings = This->buf.pstrings = object->pstrings = pstrings; if (!parse_object(&This->buf)) { diff --git a/dlls/d3dxof/d3dxof_private.h b/dlls/d3dxof/d3dxof_private.h index d7cd9c8d56e..58b0416cb42 100644 --- a/dlls/d3dxof/d3dxof_private.h +++ b/dlls/d3dxof/d3dxof_private.h @@ -104,6 +104,7 @@ typedef struct { int cur_enum_object; BOOL from_ref; ULONG level; + LPBYTE pdata; LPBYTE pstrings; } IDirectXFileDataImpl;