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

> [wsimpson - Jeu. AoĆ». 16 15:33:37 2007]:
> 
> Pepeto _ wrote:
> > But wipe_unit(vunit) in 2.0 is needed, because transfer_unit() makes
> > already a new unit. In 2.1, the same structure is used, so there is no
> > problem.
> > 
> Then that's a bug in transfer_unit().  My fix prevents a reported crash in
> the following line at unit_list_unlink, an invalid vunit.  You cannot wipe
> the unit before unlinking:
> 
>    wipe_unit(vunit);
>    unit_list_unlink(units, vunit);
> 
> Clearly, you never tested your proposed patch.  That makes all your other
> patches suspect.
I tested my patch. It doesn't crash since you don't use vunit as a
structure but as a pointer. But, you are right, it's better to call
unit_list_unlink() before. See the attached patch...

> Moreover, the code in 2.0 is so bad, it's a waste of time.  Live with
> 2.0.9!
No comment...
--- server/citytools.c.old	2007-08-16 17:32:00.000000000 +0200
+++ server/citytools.c	2007-08-16 19:16:26.000000000 +0200
@@ -620,6 +620,7 @@
       if (unit_owner(vunit) == pvictim) {
 	transfer_unit(vunit, pcity, verbose);
 	unit_list_unlink(units, vunit);
+        wipe_unit(vunit);
       } else if (!pplayers_allied(pplayer, unit_owner(vunit))) {
         /* the owner of vunit is allied to pvictim but not to pplayer */
         bounce_unit(vunit, verbose);
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to