summaryrefslogtreecommitdiff
path: root/src/net/ea/playerhandler.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-07-04 21:11:28 +0300
committerAndrei Karas <akaras@inbox.ru>2013-07-04 21:11:28 +0300
commit8dd47e51d9c318e522b21f28bc3e3935ef692056 (patch)
tree30b364f3f1b04fd31efec47332d193567894997f /src/net/ea/playerhandler.cpp
parentd1d205fbe0c2d63bbd08742c56f00852ccc0523b (diff)
downloadmv-8dd47e51d9c318e522b21f28bc3e3935ef692056.tar.gz
mv-8dd47e51d9c318e522b21f28bc3e3935ef692056.tar.bz2
mv-8dd47e51d9c318e522b21f28bc3e3935ef692056.tar.xz
mv-8dd47e51d9c318e522b21f28bc3e3935ef692056.zip
add missing checks.
also fix crash in creating character with broken data.
Diffstat (limited to 'src/net/ea/playerhandler.cpp')
-rw-r--r--src/net/ea/playerhandler.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/net/ea/playerhandler.cpp b/src/net/ea/playerhandler.cpp
index 5e847f88f..446766b56 100644
--- a/src/net/ea/playerhandler.cpp
+++ b/src/net/ea/playerhandler.cpp
@@ -157,7 +157,11 @@ static const char *randomDeathMessage()
N_("You're pining for the fjords.")
};
- const int random = static_cast<int>(rand() % (sizeof(deadMsg)
+ const int sz = sizeof(deadMsg);
+ if (!sz)
+ return gettext(deadMsg[0]);
+
+ const int random = static_cast<int>(rand() % (sz
/ sizeof(deadMsg[0])));
return gettext(deadMsg[random]);
}