From 9ac60dfa42424683256b158b03331d110abea367 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Wed, 22 Apr 2020 10:32:28 +0200 Subject: [PATCH] Ensure no invalid move pointer is passed to LearnMove. --- src/Battling/Pokemon/CreatePokemon.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Battling/Pokemon/CreatePokemon.cpp b/src/Battling/Pokemon/CreatePokemon.cpp index a6c07d7..e68b1c3 100644 --- a/src/Battling/Pokemon/CreatePokemon.cpp +++ b/src/Battling/Pokemon/CreatePokemon.cpp @@ -144,13 +144,14 @@ PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::WithHeldItem PkmnLib::Battling::CreatePokemon* PkmnLib::Battling::CreatePokemon::LearnMove(const Arbutils::CaseInsensitiveConstString& moveName, CreatureLib::Battling::AttackLearnMethod method) { - const PkmnLib::Library::MoveData* move; + const PkmnLib::Library::MoveData* move = nullptr; if (!_library->GetMoveLibrary()->TryGet(moveName, move)) { throw CreatureException("Invalid Move given: " + moveName.std_str()); } if (_attacks.size() >= _library->GetSettings()->GetMaximalMoves()) { throw CreatureException("This pokemon already has the maximal allowed moves."); } + Assert(move != nullptr); _attacks.emplace_back(move, method); return this; }