[Bug Fix] Fix possible crash in #givemoney. (#1828)

This commit is contained in:
Kinglykrab
2021-11-25 13:55:06 -05:00
committed by GitHub
parent 1a5f48521d
commit d38b8a4867
2 changed files with 19 additions and 14 deletions
+4 -4
View File
@@ -14,10 +14,10 @@ void command_givemoney(Client *c, const Seperator *sep)
target = c->GetTarget()->CastToClient();
}
uint32 platinum = std::stoi(sep->arg[1]);
uint32 gold = std::stoi(sep->arg[2]);
uint32 silver = std::stoi(sep->arg[3]);
uint32 copper = std::stoi(sep->arg[4]);
uint32 platinum = std::stoul(sep->arg[1]);
uint32 gold = sep->IsNumber(2) ? std::stoul(sep->arg[2]) : 0;
uint32 silver = sep->IsNumber(3) ? std::stoul(sep->arg[3]) : 0;
uint32 copper = sep->IsNumber(4) ? std::stoul(sep->arg[4]) : 0;
if (!platinum && !gold && !silver && !copper) {
c->Message(Chat::Red, "Usage: #Usage: #givemoney [Platinum] [Gold] [Silver] [Copper]");
return;