From fe19bdaf446f5ea98c5a6ada124fc238cdf02314 Mon Sep 17 00:00:00 2001 From: Jyrki Vesterinen Date: Mon, 23 Apr 2018 19:29:19 +0300 Subject: [PATCH] Fix rare crash in AI code Reported in https://forums.wesnoth.org/viewtopic.php?p=626344#p626344 Regression from commit a3d5b9d603083ab0f3afcfbc9fc4c2432bb1623e. The crash occurred when * the attacker had only one weapon * the said weapon was disabled, and - the defender had no weapons - the defender had only one weapon, or - all defender's weapons were disabled (cherry-picked from commit 4d569815d00fc0bb7be9fcc83705ebbf9a680bd8) --- src/actions/attack.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/actions/attack.cpp b/src/actions/attack.cpp index 5f4c92c6f0ea..1e5ae7c43980 100644 --- a/src/actions/attack.cpp +++ b/src/actions/attack.cpp @@ -563,6 +563,7 @@ int battle_context::choose_attacker_weapon(const unit& attacker, attacker, attacker_loc, choices[0], true, defender, defender_loc, def_weapon, units)); if(attacker_stats_->disable) { + attacker_stats_.reset(); return -1; }