Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2004:
[Freeciv-Dev] (PR#10415) segfault in map_distance_vector() called from
Home

[Freeciv-Dev] (PR#10415) segfault in map_distance_vector() called from

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: marko.lindqvist@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#10415) segfault in map_distance_vector() called from ... ai_hunter_manage()
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 3 Oct 2004 23:18:14 -0700
Reply-to: rt@xxxxxxxxxxx

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

> [marko.lindqvist@xxxxxxxxxxx - Mon Oct 04 04:59:10 2004]:
> 
> 
>   Another map_distance_vector() segfault. This time it originates from 
> hut_get_barbarians().

This looks like a bad-and-impossible-to-catch bug that was converted
into an even-worse-but-easy-to-catch one.  I really have no idea what
the barbarians code is supposed to be doing here so I have no idea how
to "fix" it.  But this patch prevents the bug.  It seems likely there
are more bugs (Mike and I looked at this code when he committed the
patch, but other than the if(utile) check we added at the bottom we
didn't know what to do with it then either).

jason

Index: server/barbarian.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/barbarian.c,v
retrieving revision 1.79
diff -u -r1.79 barbarian.c
--- server/barbarian.c  29 Sep 2004 02:24:23 -0000      1.79
+++ server/barbarian.c  4 Oct 2004 06:16:32 -0000
@@ -238,6 +238,8 @@
     if (sea_cnt > 0) {         /* maybe it's an island, try to get on boats */
       struct tile *btile = NULL;
 
+      /* FIXME: If anyone knows what this code is supposed to do, rewrite
+       * this comment to explain it. */
       unit_list_iterate((ptile)->units, punit2) {
         if (punit2->owner == me) {
           send_unit_info(NULL, punit2);
@@ -246,7 +248,7 @@
            if (can_unit_move_to_tile(punit2, utile, TRUE)) {
              break;
             }
-           if (can_unit_move_to_tile(punit2, btile, TRUE)) {
+           if (btile && can_unit_move_to_tile(punit2, btile, TRUE)) {
              utile = btile;
               break;
            }

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