Module: wine Branch: master Commit: 1752f36413126001c2355aba244dfecc4a4abafc URL: http://source.winehq.org/git/wine.git/?a=commit;h=1752f36413126001c2355aba24...
Author: Misha Koshelev mk144210@bcm.edu Date: Thu May 3 19:01:10 2007 -0500
msi/tests: automation: Free memory after string conversion.
---
dlls/msi/tests/automation.c | 15 +++++++++------ 1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/dlls/msi/tests/automation.c b/dlls/msi/tests/automation.c index 475eb3b..999a3cd 100644 --- a/dlls/msi/tests/automation.c +++ b/dlls/msi/tests/automation.c @@ -334,16 +334,19 @@ static DISPID get_dispid( IDispatch *disp, const char *name ) { LPOLESTR str; UINT len; - DISPID id; + DISPID id = -1; HRESULT r;
len = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0 ); str = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR) ); - len = MultiByteToWideChar(CP_ACP, 0, name, -1, str, len ); - - r = IDispatch_GetIDsOfNames( disp, &IID_NULL, &str, 1, 0, &id ); - if (r != S_OK) - return -1; + if (str) + { + len = MultiByteToWideChar(CP_ACP, 0, name, -1, str, len ); + r = IDispatch_GetIDsOfNames( disp, &IID_NULL, &str, 1, 0, &id ); + HeapFree(GetProcessHeap(), 0, str); + if (r != S_OK) + return -1; + }
return id; }