diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-30 21:10:56 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2011-08-30 21:10:56 +0200 |
commit | 36611913651e26bcb580e7cca28b396a38a7f0fc (patch) | |
tree | 8b4c7f2a4079f46ace2453a368c84f7e6b535039 | |
parent | 5661e7d0ce2c3233d302d65ac4cd7b016af27cde (diff) | |
download | manaserv-36611913651e26bcb580e7cca28b396a38a7f0fc.tar.gz manaserv-36611913651e26bcb580e7cca28b396a38a7f0fc.tar.bz2 manaserv-36611913651e26bcb580e7cca28b396a38a7f0fc.tar.xz manaserv-36611913651e26bcb580e7cca28b396a38a7f0fc.zip |
Avoid crashing the game server when the last argument is quoted.
Resolves: Mana-Mantis #386
-rw-r--r-- | src/game-server/commandhandler.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
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 |