From 6bcd8fea189d52070184da1dbbb6051328d0c385 Mon Sep 17 00:00:00 2001 From: Alex King <89047260+Kinglykrab@users.noreply.github.com> Date: Fri, 24 May 2024 19:27:43 -0400 Subject: [PATCH] [Bug Fix] Fix Crash with null Argument in #modifynpcstat (#4318) * [Bug Fix] Fix Crash with null Argument in #modifynpcstat * Update modifynpcstat.cpp * Update modifynpcstat.cpp --- zone/gm_commands/modifynpcstat.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zone/gm_commands/modifynpcstat.cpp b/zone/gm_commands/modifynpcstat.cpp index 75047caf9..463e625f1 100755 --- a/zone/gm_commands/modifynpcstat.cpp +++ b/zone/gm_commands/modifynpcstat.cpp @@ -16,8 +16,14 @@ void command_modifynpcstat(Client *c, const Seperator *sep) auto target = c->GetTarget()->CastToNPC(); - std::string stat = sep->arg[1]; - std::string value = sep->arg[2] ? sep->arg[2] : ""; + const std::string& stat = sep->arg[1] ? sep->arg[1] : ""; + const std::string& value = sep->arg[2] ? sep->arg[2] : ""; + + if (stat.empty() || value.empty()) { + c->Message(Chat::White, "Usage: #modifynpcstat [Stat] [Value]"); + ListModifyNPCStatMap(c); + return; + } auto stat_description = GetModifyNPCStatDescription(stat); if (!stat_description.length()) {