Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2004:
[Freeciv-Dev] (PR#10983) unsafe unit_list_iterate in city autoattack cod
Home

[Freeciv-Dev] (PR#10983) unsafe unit_list_iterate in city autoattack cod

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: joshudson@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10983) unsafe unit_list_iterate in city autoattack code
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 16 Nov 2004 14:13:34 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=10983 >

So here's a patch that just fixes the problem.

-jason

Index: server/autoattack.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/Attic/autoattack.c,v
retrieving revision 1.51
diff -u -r1.51 autoattack.c
--- server/autoattack.c 29 Sep 2004 02:24:23 -0000      1.51
+++ server/autoattack.c 16 Nov 2004 21:46:02 -0000
@@ -224,14 +224,13 @@
 **************************************************************************/
 static void auto_attack_city(struct player *pplayer, struct city *pcity)
 {
-  unit_list_iterate(pcity->tile->units, punit) {
+  unit_list_iterate_safe(pcity->tile->units, punit) {
     if (punit->ai.control
        && punit->activity == ACTIVITY_IDLE
        && is_military_unit(punit)) {
       auto_attack_with_unit(pplayer, pcity, punit);
     }
-  }
-  unit_list_iterate_end;
+  } unit_list_iterate_safe_end;
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]