From 4deff8569279d5cf23a73fdc1c986592ca4f7ed2 Mon Sep 17 00:00:00 2001 From: Kess Vargavind Date: Thu, 21 May 2009 00:00:24 +0200 Subject: Fix a segmentation fault The client crashed when entering [] inside an item link, for example the string [[]]. (cherry picked from commit 86a055d46df5a262fce0f76697cc3d54e75b19e1) --- src/gui/widgets/chattab.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp index 711680d1..85353bf7 100644 --- a/src/gui/widgets/chattab.cpp +++ b/src/gui/widgets/chattab.cpp @@ -227,15 +227,19 @@ void ChatTab::chatInput(std::string &msg) std::string temp = msg.substr(start + 1, end - start - 1); - toLower(trim(temp)); - - const ItemInfo itemInfo = ItemDB::get(temp); - if (itemInfo.getName() != _("Unknown item")) + // Do not parse an empty string (it crashes the client) + if (!temp.empty()) { - msg.insert(end, "@@"); - msg.insert(start+1, "|"); - msg.insert(start+1, toString(itemInfo.getId())); - msg.insert(start+1, "@@"); + toLower(trim(temp)); + + const ItemInfo itemInfo = ItemDB::get(temp); + if (itemInfo.getName() != _("Unknown item")) + { + msg.insert(end, "@@"); + msg.insert(start+1, "|"); + msg.insert(start+1, toString(itemInfo.getId())); + msg.insert(start+1, "@@"); + } } } start = msg.find('[', start + 1); -- cgit v1.2.3-70-g09d2