summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKess Vargavind <vargavind@gmail.com>2009-05-21 00:00:24 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-23 13:15:59 +0200
commit4deff8569279d5cf23a73fdc1c986592ca4f7ed2 (patch)
tree693824fb71360c8a54cb7ddd406c88572d18ca74 /src
parent1407a08f0087905edae30ac3793e83757ff56d4c (diff)
downloadmana-4deff8569279d5cf23a73fdc1c986592ca4f7ed2.tar.gz
mana-4deff8569279d5cf23a73fdc1c986592ca4f7ed2.tar.bz2
mana-4deff8569279d5cf23a73fdc1c986592ca4f7ed2.tar.xz
mana-4deff8569279d5cf23a73fdc1c986592ca4f7ed2.zip
Fix a segmentation fault
The client crashed when entering [] inside an item link, for example the string [[]]. (cherry picked from commit 86a055d46df5a262fce0f76697cc3d54e75b19e1)
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/chattab.cpp20
1 files changed, 12 insertions, 8 deletions
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);