summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM/src/chat/message.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-12-24 15:03:40 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-12-24 15:03:40 +0000
commit0851c3965879663c41cfe435d1b320ba68cf873a (patch)
tree9959d614cfb7923654842a577a48d38128fafcc9 /plugins/TabSRMM/src/chat/message.cpp
parent7bf458c314a911bedabc7c987b7ab352153248c1 (diff)
fix for crash in RTF parser
git-svn-id: http://svn.miranda-ng.org/main/trunk@2830 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/TabSRMM/src/chat/message.cpp')
-rw-r--r--plugins/TabSRMM/src/chat/message.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/plugins/TabSRMM/src/chat/message.cpp b/plugins/TabSRMM/src/chat/message.cpp
index 71fbba7276..48ccf0ff64 100644
--- a/plugins/TabSRMM/src/chat/message.cpp
+++ b/plugins/TabSRMM/src/chat/message.cpp
@@ -84,13 +84,10 @@ static int ReadInteger(const char* p, int* result)
TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO* si)
{
- char *p1;
- int* pIndex;
int i, iRemoveChars, cp = CP_ACP;
char InsertThis[50];
BOOL bJustRemovedRTF = TRUE;
BOOL bTextHasStarted = FALSE;
- TCHAR *ptszResult; //, *d;
int iUcMode = 0;
if (!pszText)
@@ -98,20 +95,20 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO* si)
// create an index of colors in the module and map them to
// corresponding colors in the RTF color table
- pIndex = (int *)mir_alloc(sizeof(int) * MM_FindModule(si->pszModule)->nColorCount);
+ mir_ptr<int> pIndex((int*)mir_alloc(sizeof(int) * MM_FindModule(si->pszModule)->nColorCount));
for (i=0; i < MM_FindModule(si->pszModule)->nColorCount ; i++)
pIndex[i] = -1;
CreateColorMap(pszText, pIndex, si);
// scan the file for rtf commands and remove or parse them
- p1 = strstr(pszText, "\\pard");
+ char *p1 = strstr(pszText, "\\ltrpar");
if (p1 == NULL) {
- mir_free(pIndex);
- return FALSE;
+ if ((p1 = strstr(pszText, "\\pard")) == NULL)
+ return FALSE;
+ p1 += 5;
}
-
- p1 += 5;
+ else p1 += 7;
MoveMemory(pszText, p1, lstrlenA(p1) + 1);
p1 = pszText;
@@ -293,9 +290,7 @@ TCHAR* Chat_DoRtfToTags(char* pszText, SESSION_INFO* si)
} else p1++;
}
- mir_free(pIndex);
- ptszResult = mir_utf8decodeW(pszText);
- return ptszResult;
+ return mir_utf8decodeW(pszText);
}
static DWORD CALLBACK Chat_Message_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)