From 0851c3965879663c41cfe435d1b320ba68cf873a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 24 Dec 2012 15:03:40 +0000 Subject: fix for crash in RTF parser git-svn-id: http://svn.miranda-ng.org/main/trunk@2830 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TabSRMM/src/chat/window.cpp | 67 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 35 deletions(-) (limited to 'plugins/TabSRMM/src/chat/window.cpp') diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index 6d85d6244a..4f86fe2654 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -3153,44 +3153,41 @@ LABEL_SHOWWINDOW: ShowWindow(dat->pContainer->hwnd, SW_MINIMIZE); return FALSE; - case IDOK: { - char* pszRtf; - TCHAR* ptszText/*, *p1*/; - MODULEINFO* mi; - bool fSound = true; + case IDOK: + if (GetSendButtonState(hwndDlg) != PBS_DISABLED) { + MODULEINFO *mi = MM_FindModule(si->pszModule); - if (GetSendButtonState(hwndDlg) == PBS_DISABLED) - break; + mir_ptr pszRtf( Chat_Message_GetFromStream(hwndDlg, si)); + SM_AddCommand(si->ptszID, si->pszModule, pszRtf); + + mir_ptr ptszText( Chat_DoRtfToTags(pszRtf, si)); + if ((TCHAR*)ptszText == NULL) + break; + + DoTrimMessage(ptszText); - mi = MM_FindModule(si->pszModule); - - pszRtf = Chat_Message_GetFromStream(hwndDlg, si); - SM_AddCommand(si->ptszID, si->pszModule, pszRtf); - ptszText = Chat_DoRtfToTags(pszRtf, si); - DoTrimMessage(ptszText); - - if (mi && mi->bAckMsg) { - Utils::enableDlgControl(hwndDlg, IDC_CHAT_MESSAGE, FALSE); - SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETREADONLY, TRUE, 0); - } else SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, WM_SETTEXT, 0, (LPARAM)_T("")); - - Utils::enableDlgControl(hwndDlg, IDOK, FALSE); - - if (ptszText[0] == '/' || si->iType == GCW_SERVER) - fSound = false; - DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0); - mi->idleTimeStamp = time(0); - mi->lastIdleCheck = 0; - SM_BroadcastMessage(si->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE); - if (dat && dat->pContainer) { - if (fSound && !nen_options.iNoSounds && !(dat->pContainer->dwFlags & CNT_NOSOUND)) - SkinPlaySound("ChatSent"); + if (mi && mi->bAckMsg) { + Utils::enableDlgControl(hwndDlg, IDC_CHAT_MESSAGE, FALSE); + SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, EM_SETREADONLY, TRUE, 0); + } + else SendDlgItemMessage(hwndDlg, IDC_CHAT_MESSAGE, WM_SETTEXT, 0, (LPARAM)_T("")); + + Utils::enableDlgControl(hwndDlg, IDOK, FALSE); + + bool fSound = true; + if (ptszText[0] == '/' || si->iType == GCW_SERVER) + fSound = false; + DoEventHookAsync(hwndDlg, si->ptszID, si->pszModule, GC_USER_MESSAGE, NULL, ptszText, 0); + mi->idleTimeStamp = time(0); + mi->lastIdleCheck = 0; + SM_BroadcastMessage(si->pszModule, GC_UPDATESTATUSBAR, 0, 1, TRUE); + if (dat && dat->pContainer) + if (fSound && !nen_options.iNoSounds && !(dat->pContainer->dwFlags & CNT_NOSOUND)) + SkinPlaySound("ChatSent"); + + SetFocus(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE)); } - mir_free(pszRtf); - mir_free(ptszText); - SetFocus(GetDlgItem(hwndDlg, IDC_CHAT_MESSAGE)); - } - break; + break; case IDC_SHOWNICKLIST: if (!IsWindowEnabled(GetDlgItem(hwndDlg, IDC_SHOWNICKLIST))) -- cgit v1.2.3