From 8dd47e51d9c318e522b21f28bc3e3935ef692056 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 4 Jul 2013 21:11:28 +0300 Subject: add missing checks. also fix crash in creating character with broken data. --- src/net/ea/playerhandler.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/net/ea') 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(rand() % (sizeof(deadMsg) + const int sz = sizeof(deadMsg); + if (!sz) + return gettext(deadMsg[0]); + + const int random = static_cast(rand() % (sz / sizeof(deadMsg[0]))); return gettext(deadMsg[random]); } -- cgit v1.2.3-70-g09d2