From cd50b2c2e87cad852bfc0ab488e41b6ff7904180 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 14 May 2022 14:56:00 +0200 Subject: [PATCH] Fixed nullptr dereference in ItemUse --- src/Battling/Flow/TurnHandler.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Battling/Flow/TurnHandler.cpp b/src/Battling/Flow/TurnHandler.cpp index decf921..c45a1e1 100644 --- a/src/Battling/Flow/TurnHandler.cpp +++ b/src/Battling/Flow/TurnHandler.cpp @@ -368,7 +368,10 @@ void TurnHandler::ExecuteItemChoice(const ArbUt::BorrowedPtr& ch return; } auto* script = battle.GetValue()->GetLibrary()->GetScriptResolver()->LoadItemScript(choice->GetItem()); - auto targetIndex = choice->GetTarget(); + if (script == nullptr) { + return; + } + const auto& targetIndex = choice->GetTarget(); ArbUt::OptionalBorrowedPtr target = nullptr; if (targetIndex.has_value()) { target = battle.GetValue()->GetCreature(targetIndex.value());