diff options
author | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-11-25 20:29:32 +0000 |
---|---|---|
committer | Rozhuk Ivan <rozhuk.im@gmail.com> | 2014-11-25 20:29:32 +0000 |
commit | 91d5b91fe12c9733db9fd4d8eb84bfbe674b0a2c (patch) | |
tree | 30abd84eb2aa65aa9e9b2509fe3d16df4340f685 /plugins/TabSRMM/src/generic_msghandlers.cpp | |
parent | 98c9aad15f13fe27c6a456836c88b94e364a5068 (diff) |
TabSRMM null ptr fixes and code cleanup
require for review.
git-svn-id: http://svn.miranda-ng.org/main/trunk@11065 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/generic_msghandlers.cpp')
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 34799804d3..4daa1700f3 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -1104,25 +1104,27 @@ LRESULT TSAPI DM_WMCopyHandler(HWND hwnd, WNDPROC oldWndProc, UINT msg, WPARAM w { LRESULT result = mir_callNextSubclass(hwnd, oldWndProc, msg, wParam, lParam); - if (OpenClipboard(hwnd)) { - HANDLE hClip = GetClipboardData(CF_UNICODETEXT); - if (hClip) { - TCHAR *tszText = (TCHAR*)mir_alloc((lstrlen((TCHAR*)hClip) + 2) * sizeof(TCHAR)); - - lstrcpy(tszText, (TCHAR*)hClip); - Utils::FilterEventMarkers(tszText); - EmptyClipboard(); - - HGLOBAL hgbl = GlobalAlloc(GMEM_MOVEABLE, (lstrlen(tszText) + 1) * sizeof(TCHAR)); - TCHAR *tszLocked = (TCHAR*)GlobalLock(hgbl); - lstrcpy(tszLocked, tszText); - GlobalUnlock(hgbl); - SetClipboardData(CF_UNICODETEXT, hgbl); - if (tszText) - mir_free(tszText); - } - CloseClipboard(); - } + if (!OpenClipboard(hwnd)) + return result; + HANDLE hClip = GetClipboardData(CF_UNICODETEXT); + if (!hClip) + goto err_out; + TCHAR *tszText = (TCHAR*)mir_alloc((lstrlen((TCHAR*)hClip) + 2) * sizeof(TCHAR)); + if (!tszText) + goto err_out; + lstrcpy(tszText, (TCHAR*)hClip); + Utils::FilterEventMarkers(tszText); + EmptyClipboard(); + + HGLOBAL hgbl = GlobalAlloc(GMEM_MOVEABLE, (lstrlen(tszText) + 1) * sizeof(TCHAR)); + TCHAR *tszLocked = (TCHAR*)GlobalLock(hgbl); + lstrcpy(tszLocked, tszText); + GlobalUnlock(hgbl); + SetClipboardData(CF_UNICODETEXT, hgbl); + mir_free(tszText); + +err_out: + CloseClipboard(); return result; } |