From 36611913651e26bcb580e7cca28b396a38a7f0fc Mon Sep 17 00:00:00 2001 From: Yohann Ferreira Date: Tue, 30 Aug 2011 21:10:56 +0200 Subject: Avoid crashing the game server when the last argument is quoted. Resolves: Mana-Mantis #386 --- src/game-server/commandhandler.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/game-server/commandhandler.cpp b/src/game-server/commandhandler.cpp index f0cbcf3b..189da538 100644 --- a/src/game-server/commandhandler.cpp +++ b/src/game-server/commandhandler.cpp @@ -186,7 +186,15 @@ static std::string getArgument(std::string &args) // Jumps to the next parameter, // after the ending double-quote and space, // and remove the two double-quotes before returning. - args = args.substr(pos + 2); + if (pos + 2 < args.size()) + { + args = args.substr(pos + 2); + } + else + { + // This was the last argument + args.clear(); + } argument = argument.substr(1, pos - 1); } else -- cgit v1.2.3-70-g09d2