summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-04-19 10:45:43 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-04-19 10:45:43 +0000
commitf120ea5bc4b312d62b002439c31b96596500b3dc (patch)
tree8f1e7b34d272f40436e9a5430eac4ee50ec91865
parent828d3d3cc4244db17bd56a8ed6122cc8ebc11fd2 (diff)
fix against very rare & strange crash
git-svn-id: http://svn.miranda-ng.org/main/trunk@12933 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index a635cbed20..bc19a5b87a 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -2816,18 +2816,18 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
db_event_get(hDBEvent, &dbei);
int iSize = int(strlen((char*)dbei.pBlob)) + 1;
- bool iAlloced = false;
+ bool bNeedsFree = false;
TCHAR *szConverted;
if (dbei.flags & DBEF_UTF) {
szConverted = mir_utf8decodeW((char*)szText);
- iAlloced = true;
+ bNeedsFree = true;
}
else {
if (iSize != (int)dbei.cbBlob)
szConverted = (TCHAR*)&dbei.pBlob[iSize];
else {
szConverted = (TCHAR*)mir_alloc(sizeof(TCHAR) * iSize);
- iAlloced = true;
+ bNeedsFree = true;
MultiByteToWideChar(CP_ACP, 0, (char*)dbei.pBlob, -1, szConverted, iSize);
}
}
@@ -2839,12 +2839,14 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
szText[iDescr + 1] = '\n';
szConverted = (TCHAR*)mir_alloc(sizeof(TCHAR)* (1 + mir_strlen((char *)szText)));
MultiByteToWideChar(CP_ACP, 0, (char *)szText, -1, szConverted, 1 + (int)mir_strlen((char *)szText));
- iAlloced = true;
+ bNeedsFree = true;
+ }
+ if (szConverted != NULL) {
+ ptrT szQuoted(QuoteText(szConverted));
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)szQuoted);
}
- ptrT szQuoted(QuoteText(szConverted));
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETTEXTEX, (WPARAM)&stx, (LPARAM)szQuoted);
mir_free(szText);
- if (iAlloced)
+ if (bNeedsFree)
mir_free(szConverted);
}
else {