Author: anonymissimus
Date: Fri Mar 30 17:44:52 2012
New Revision: 53697

URL: http://svn.gna.org/viewcvs/wesnoth?rev=53697&view=rev
Log:
Fix usage of invalid iterators in [effect]apply_to=remove_attacks.

Revealed (not introduced) by r53470, causing the debugger to crash.

backported from trunk r53549

Modified:
    branches/1.10/src/unit.cpp

Modified: branches/1.10/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/1.10/src/unit.cpp?rev=53697&r1=53696&r2=53697&view=diff
==============================================================================
--- branches/1.10/src/unit.cpp (original)
+++ branches/1.10/src/unit.cpp Fri Mar 30 17:44:52 2012
@@ -2387,10 +2387,13 @@
                                } else if(apply_to == "new_attack") {
                                        attacks_.push_back(attack_type(effect));
                                } else if(apply_to == "remove_attacks") {
-                                       for(std::vector<attack_type>::iterator 
a = attacks_.begin(); a != attacks_.end(); ++a) {
-                                               if (a->matches_filter(effect, 
false)) {
-                                                       attacks_.erase(a--);
+                                       std::vector<attack_type>::iterator a = 
attacks_.begin();
+                                       while(a != attacks_.end()) {
+                                               if(a->matches_filter(effect, 
false)) {
+                                                       a = attacks_.erase(a);
+                                                       continue;
                                                }
+                                               ++a;
                                        }
                                } else if(apply_to == "attack") {
 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to