Module: wine Branch: master Commit: 64bcb540bb8f147f1f4e652043247c07bf50e570 URL: http://source.winehq.org/git/wine.git/?a=commit;h=64bcb540bb8f147f1f4e652043...
Author: Detlef Riekenberg wine.dev@web.de Date: Tue Sep 29 13:35:45 2009 +0200
localui: Fix a memory leak.
---
dlls/localui/localui.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/dlls/localui/localui.c b/dlls/localui/localui.c index 2acfc7e..b9e4c4e 100644 --- a/dlls/localui/localui.c +++ b/dlls/localui/localui.c @@ -503,7 +503,6 @@ static BOOL WINAPI localui_AddPortUI(PCWSTR pName, HWND hWnd, PCWSTR pMonitorNam { addportui_t data; HANDLE hXcv; - LPWSTR ptr = NULL; DWORD needed; DWORD dummy; DWORD status; @@ -529,14 +528,11 @@ static BOOL WINAPI localui_AddPortUI(PCWSTR pName, HWND hWnd, PCWSTR pMonitorNam (PBYTE) &dummy, 0, &needed, &status);
TRACE("got %u with status %u\n", res, status); - if (res && (status == ERROR_SUCCESS)) { + if (res && (status == ERROR_SUCCESS) && ppPortName) { /* Native localui uses GlobalAlloc also. The caller must GlobalFree the buffer */ - ptr = GlobalAlloc(GPTR, (lstrlenW(data.portname)+1) * sizeof(WCHAR)); - if (ptr) { - lstrcpyW(ptr, data.portname); - if (ppPortName) *ppPortName = ptr; - } + *ppPortName = GlobalAlloc(GPTR, (lstrlenW(data.portname)+1) * sizeof(WCHAR)); + if (*ppPortName) lstrcpyW(*ppPortName, data.portname); }
if (res && (status == ERROR_ALREADY_EXISTS)) {