Scripts/Commands: Fix crash in ".kick" command

Fix a NULL dereference exception happening when using .kick command caused by a strtok(NULL) call without a previous call to the string to be tokenized.
Issue added in 101cad1f28
This commit is contained in:
jackpoz
2014-03-09 17:09:15 +01:00
parent de91f716a4
commit d357597270

View File

@@ -809,10 +809,13 @@ public:
if (handler->HasLowerSecurity(target, 0))
return false;
char const* kickReason = strtok(NULL, "\r");
std::string kickReasonStr = "No reason";
if (kickReason != NULL)
kickReasonStr = kickReason;
if (*args != '\0')
{
char const* kickReason = strtok(NULL, "\r");
if (kickReason != NULL)
kickReasonStr = kickReason;
}
if (sWorld->getBoolConfig(CONFIG_SHOW_KICK_IN_WORLD))
sWorld->SendWorldText(LANG_COMMAND_KICKMESSAGE_WORLD, (handler->GetSession() ? handler->GetSession()->GetPlayerName().c_str() : "Server"), playerName.c_str(), kickReasonStr.c_str());