From 63611a72e967abd262e35d8683d9e14126accd68 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 29 Nov 2014 13:57:25 +0000 Subject: memory allocation fix git-svn-id: http://svn.miranda-ng.org/main/trunk@11149 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/CrashDumper/src/crshdmp.cpp | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'plugins/CrashDumper') diff --git a/plugins/CrashDumper/src/crshdmp.cpp b/plugins/CrashDumper/src/crshdmp.cpp index 53a0a5a389..ccc560205a 100644 --- a/plugins/CrashDumper/src/crshdmp.cpp +++ b/plugins/CrashDumper/src/crshdmp.cpp @@ -158,21 +158,23 @@ INT_PTR OpenUrl(WPARAM wParam, LPARAM) INT_PTR CopyLinkToClipboard(WPARAM, LPARAM) { - TCHAR *tmp; - TCHAR buffer[MAX_PATH]; - - tmp = db_get_wsa(NULL, PluginName, "Username"); - mir_sntprintf(buffer, SIZEOF(buffer), _T("http://vi.miranda-ng.org/detail/%s"), tmp); - int bufLen = (sizeof(buffer) + 1) * sizeof(TCHAR); - HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, bufLen); - LPSTR buf = (LPSTR)GlobalLock(hData); - memcpy(buf, buffer, bufLen); - - OpenClipboard(NULL); - EmptyClipboard(); - - SetClipboardData(CF_UNICODETEXT, hData); - CloseClipboard(); + ptrT tmp(db_get_wsa(NULL, PluginName, "Username")); + if (tmp != NULL) { + TCHAR buffer[MAX_PATH]; + mir_sntprintf(buffer, SIZEOF(buffer), _T("http://vi.miranda-ng.org/detail/%s"), tmp); + + int bufLen = (sizeof(buffer) + 1) * sizeof(TCHAR); + HANDLE hData = GlobalAlloc(GMEM_MOVEABLE, bufLen); + LPSTR buf = (LPSTR)GlobalLock(hData); + memcpy(buf, buffer, bufLen); + + OpenClipboard(NULL); + EmptyClipboard(); + + if (SetClipboardData(CF_UNICODETEXT, hData) == NULL) + GlobalFree(hData); + CloseClipboard(); + } return 0; } -- cgit v1.2.3