From 972f30762ab2dcbe1f2662b6014f1cfccf56fe16 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Mon, 18 Mar 2013 14:32:02 +0000 Subject: ieview crash fix git-svn-id: http://svn.miranda-ng.org/main/trunk@4097 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/IEView/src/TextToken.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'plugins/IEView') diff --git a/plugins/IEView/src/TextToken.cpp b/plugins/IEView/src/TextToken.cpp index 0c16b6aa55..acddb91263 100644 --- a/plugins/IEView/src/TextToken.cpp +++ b/plugins/IEView/src/TextToken.cpp @@ -578,14 +578,15 @@ TextToken* TextToken::tokenizeChatFormatting(const wchar_t *text) { return firstToken; } -wchar_t *TextToken::htmlEncode(const wchar_t *str) { +wchar_t *TextToken::htmlEncode(const wchar_t *str) +{ wchar_t *out; const wchar_t *ptr; - bool wasSpace; - int c; - c = 0; - wasSpace = false; + if (str == NULL) + return NULL; + int c = 0; for (ptr=str; *ptr!='\0'; ptr++) { + bool wasSpace = false; if (*ptr==' ' && wasSpace) { wasSpace = true; c += 6; @@ -604,8 +605,8 @@ wchar_t *TextToken::htmlEncode(const wchar_t *str) { } } wchar_t *output = new wchar_t[c+1]; - wasSpace = false; for (out=output, ptr=str; *ptr!='\0'; ptr++) { + bool wasSpace = false; if (*ptr==' ' && wasSpace) { wcscpy(out, L" "); out += 6; @@ -734,16 +735,16 @@ void TextToken::toString(wchar_t **str, int *sizeAlloced) { break; case BB_IMG: eText = htmlEncode(wtext); - if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && (wcsstr(eText, L".swf")!=NULL)) { + if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && eText != NULL && (wcsstr(eText, L".swf")!=NULL)) { Utils::appendText(str, sizeAlloced, L"
\
", eText); - } else if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_PNGHACK) && (wcsstr(eText, L".png")!=NULL)) { + } else if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_PNGHACK) && eText != NULL && (wcsstr(eText, L".png")!=NULL)) { Utils::appendText(str, sizeAlloced, L"", eText); } else { - if (wcsncmp(eText, L"http://", 7)) { + if (eText != NULL && wcsncmp(eText, L"http://", 7)) { Utils::appendText(str, sizeAlloced, L"
this.width ? 'auto' : maxw);\" src=\"file://%s\" />
", eText); } else { Utils::appendText(str, sizeAlloced, L"
this.width ? 'auto' : maxw);\" src=\"%s\" />
", eText); -- cgit v1.2.3