From e1e08be0251fa45586dca10dfa366e647f08cd8b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 18 Jan 2016 08:09:42 +0000 Subject: memory allocation conflict fixed git-svn-id: http://svn.miranda-ng.org/main/trunk@16118 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/AssocMgr/src/dde.cpp | 64 +++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/plugins/AssocMgr/src/dde.cpp b/plugins/AssocMgr/src/dde.cpp index ba69dd9fac..990f6992bd 100644 --- a/plugins/AssocMgr/src/dde.cpp +++ b/plugins/AssocMgr/src/dde.cpp @@ -70,13 +70,11 @@ static void __stdcall UrlActionAsync(void *param) // returns an empty string if the string does not have enough arguments static TCHAR* GetExecuteParam(TCHAR **ppszString) { - TCHAR *pszParam, *p; - BOOL fQuoted; - - fQuoted = (**ppszString == _T('"')); - pszParam = *ppszString; - if (fQuoted) pszParam++; - p = _tcschr(pszParam, (TCHAR)(fQuoted ? _T('"') : _T(','))); + bool fQuoted = (**ppszString == _T('"')); + TCHAR *pszParam = *ppszString; + if (fQuoted) + pszParam++; + TCHAR *p = _tcschr(pszParam, (TCHAR)(fQuoted ? _T('"') : _T(','))); if (p != NULL) { *(p++) = 0; if (fQuoted && *p == _T(',')) p++; @@ -102,38 +100,36 @@ static LRESULT CALLBACK DdeMessageWindow(HWND hwnd, UINT msg, WPARAM wParam, LPA if (hSzApp) GlobalDeleteAtom(hSzApp); if (hSzTopic) GlobalDeleteAtom(hSzTopic); } - return 0; } + return 0; + case WM_DDE_EXECUTE: /* posted message */ - { - HGLOBAL hCommand; - TCHAR *pszCommand; - DDEACK ack; - memset(&ack, 0, sizeof(ack)); - if (UnpackDDElParam(msg, lParam, NULL, (PUINT_PTR)&hCommand)) { - /* ANSI execute command can't happen for shell */ - if (IsWindowUnicode((HWND)wParam)) { - pszCommand = (TCHAR*)GlobalLock(hCommand); - if (pszCommand != NULL) { - TCHAR *pszAction = GetExecuteParam(&pszCommand); - TCHAR *pszArg = GetExecuteParam(&pszCommand); - if (pszArg != NULL) { - /* we are inside miranda here, we make it async so the shell does - * not timeout regardless what the plugins try to do. */ - if (!mir_tstrcmpi(pszAction, _T("file"))) - CallFunctionAsync(FileActionAsync, pszArg); - else if (!mir_tstrcmpi(pszAction, _T("url"))) - CallFunctionAsync(UrlActionAsync, pszArg); - } - GlobalUnlock(hCommand); + HGLOBAL hCommand; + if (UnpackDDElParam(msg, lParam, NULL, (PUINT_PTR)&hCommand)) { + /* ANSI execute command can't happen for shell */ + if (IsWindowUnicode((HWND)wParam)) { + TCHAR *pszCommand = (TCHAR*)GlobalLock(hCommand); + if (pszCommand != NULL) { + TCHAR *pszAction = GetExecuteParam(&pszCommand); + TCHAR *pszArg = GetExecuteParam(&pszCommand); + if (pszArg != NULL) { + /* we are inside miranda here, we make it async so the shell does + * not timeout regardless what the plugins try to do. */ + if (!mir_tstrcmpi(pszAction, _T("file"))) + CallFunctionAsync(FileActionAsync, mir_tstrdup(pszArg)); + else if (!mir_tstrcmpi(pszAction, _T("url"))) + CallFunctionAsync(UrlActionAsync, mir_tstrdup(pszArg)); } + GlobalUnlock(hCommand); } + } - lParam = ReuseDDElParam(lParam, msg, WM_DDE_ACK, *(PUINT)&ack, (UINT_PTR)hCommand); - if (!PostMessage((HWND)wParam, WM_DDE_ACK, (WPARAM)hwnd, lParam)) { - GlobalFree(hCommand); - FreeDDElParam(WM_DDE_ACK, lParam); - } + DDEACK ack; + memset(&ack, 0, sizeof(ack)); + lParam = ReuseDDElParam(lParam, msg, WM_DDE_ACK, *(PUINT)&ack, (UINT_PTR)hCommand); + if (!PostMessage((HWND)wParam, WM_DDE_ACK, (WPARAM)hwnd, lParam)) { + GlobalFree(hCommand); + FreeDDElParam(WM_DDE_ACK, lParam); } } return 0; -- cgit v1.2.3