Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] Re: (PR#18652) [Bug] remove_illegal_armistice_units() shou
Home

[Freeciv-Dev] Re: (PR#18652) [Bug] remove_illegal_armistice_units() shou

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] Re: (PR#18652) [Bug] remove_illegal_armistice_units() should use units_iterate_safe
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Mon, 17 Jul 2006 03:29:30 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=18652 >

Marko Lindqvist wrote:
> 
>   I got segfault from remove_illegal_armistice_units(). Probably because 
> it uses normal units_iterate instead of units_iterate_safe.

  Patch


  - ML

diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c
--- freeciv/server/srv_main.c   2006-07-17 02:32:13.859375000 +0300
+++ freeciv/server/srv_main.c   2006-07-17 13:19:51.593750000 +0300
@@ -430,7 +430,7 @@
                                            struct player *plr2)
 {
   /* Remove illegal units */
-  unit_list_iterate(plr1->units, punit) {
+  unit_list_iterate_safe(plr1->units, punit) {
     if (punit->tile->owner == plr2
         && is_military_unit(punit)) {
       notify_player(plr1, NULL, E_DIPLOMACY, _("Your %s unit %s was "
@@ -440,8 +440,8 @@
                     get_nation_name_plural(plr2->nation));
       wipe_unit(punit);
     }
-  } unit_list_iterate_end;
-  unit_list_iterate(plr2->units, punit) {
+  } unit_list_iterate_safe_end;
+  unit_list_iterate_safe(plr2->units, punit) {
     if (punit->tile->owner == plr1
         && is_military_unit(punit)) {
       notify_player(plr2, NULL, E_DIPLOMACY, _("Your %s unit %s was "
@@ -451,7 +451,7 @@
                     get_nation_name_plural(plr1->nation));
       wipe_unit(punit);
     }
-  } unit_list_iterate_end;
+  } unit_list_iterate_safe_end;
 }
 
 /**************************************************************************

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#18652) [Bug] remove_illegal_armistice_units() should use units_iterate_safe, Marko Lindqvist <=