summaryrefslogtreecommitdiff
path: root/plugins/AssocMgr
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-01-18 08:09:42 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-01-18 08:09:42 +0000
commite1e08be0251fa45586dca10dfa366e647f08cd8b (patch)
tree2eb1b93afc63dae8f1246b8808ca6887d66400d7 /plugins/AssocMgr
parent223f7f273b486129a07cfc34402cd5d5dcca788e (diff)
memory allocation conflict fixed
git-svn-id: http://svn.miranda-ng.org/main/trunk@16118 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/AssocMgr')
-rw-r--r--plugins/AssocMgr/src/dde.cpp64
1 files 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;