Module: wine Branch: master Commit: c889716979326795d32df106425f94f844ff3465 URL: http://source.winehq.org/git/wine.git/?a=commit;h=c889716979326795d32df10642...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Apr 16 13:51:17 2008 +0200
fusion: Fix a number of leaks in assembly_create.
---
dlls/fusion/assembly.c | 36 ++++++++++++++++++++++++------------ 1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/dlls/fusion/assembly.c b/dlls/fusion/assembly.c index d3512e7..024e611 100644 --- a/dlls/fusion/assembly.c +++ b/dlls/fusion/assembly.c @@ -343,40 +343,52 @@ HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file)
*out = NULL;
- assembly = HeapAlloc(GetProcessHeap(), 0, sizeof(ASSEMBLY)); + assembly = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ASSEMBLY)); if (!assembly) return E_OUTOFMEMORY;
- ZeroMemory(assembly, sizeof(ASSEMBLY)); - assembly->path = strdupWtoA(file); if (!assembly->path) - return E_OUTOFMEMORY; + { + hr = E_OUTOFMEMORY; + goto failed; + }
assembly->hfile = CreateFileW(file, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (!assembly->hfile) - return HRESULT_FROM_WIN32(GetLastError()); + if (assembly->hfile == INVALID_HANDLE_VALUE) + { + hr = HRESULT_FROM_WIN32(GetLastError()); + goto failed; + }
assembly->hmap = CreateFileMappingW(assembly->hfile, NULL, PAGE_READONLY, 0, 0, NULL); if (!assembly->hmap) - return HRESULT_FROM_WIN32(GetLastError()); + { + hr = HRESULT_FROM_WIN32(GetLastError()); + goto failed; + }
assembly->data = MapViewOfFile(assembly->hmap, FILE_MAP_READ, 0, 0, 0); if (!assembly->data) - return HRESULT_FROM_WIN32(GetLastError()); + { + hr = HRESULT_FROM_WIN32(GetLastError()); + goto failed; + }
hr = parse_pe_header(assembly); - if (FAILED(hr)) - return hr; + if (FAILED(hr)) goto failed;
hr = parse_clr_metadata(assembly); - if (FAILED(hr)) - return hr; + if (FAILED(hr)) goto failed;
*out = assembly; return S_OK; + +failed: + assembly_release( assembly ); + return hr; }
HRESULT assembly_release(ASSEMBLY *assembly)