Complete.Org: Mailing Lists: Archives: freeciv-ai: December 2002:
[freeciv-ai] Re: [Freeciv-Dev] Re: (PR#2518) ai reading from raw memory?
Home

[freeciv-ai] Re: [Freeciv-Dev] Re: (PR#2518) ai reading from raw memory?

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: kaufman@xxxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-ai@xxxxxxxxxxx
Subject: [freeciv-ai] Re: [Freeciv-Dev] Re: (PR#2518) ai reading from raw memory?
From: "Per I. Mathisen via RT" <rt@xxxxxxxxxxxxxx>
Date: Mon, 9 Dec 2002 10:12:40 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Mon, 9 Dec 2002, Raimar Falke via RT wrote:
> And the two errors it found:
> ==14500== Conditional jump ormove depends on uninitialised value(s)
> ==14500==  at 0x80A12CE: contemplate_new_city (settlers.c:1565)
> ==14500==  by 0x80D0203: ai_manage_cities (aicity.c:494)
> ==14500==  by 0x80D2A82: ai_do_last_activities (aihand.c:377)
> ==14500==  by 0x804EB9E: end_turn (srv_main.c:485)
> ==14500==
> ==14500== Conditional jump or move depends on uninitialised value(s)
> ==14500==  at 0x80D49ED: copy_if_better_choice (aitools.c:451)
> ==14500==  by 0x80D39B8: ai_next_tech_goal (aitech.c:247)
> ==14500==  by 0x8084920: choose_goal_tech (plrhand.c:433)
> ==14500==  by 0x8084238: found_new_tech (plrhand.c:274)
>
> The first one is obvious. ->type is uninitialised in the second one.

Can you check if the attached patch fixes the problem?

  - Per

Index: ai/advattitude.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advattitude.c,v
retrieving revision 1.5
diff -u -r1.5 advattitude.c
--- ai/advattitude.c    14 Nov 2002 09:14:49 -0000      1.5
+++ ai/advattitude.c    9 Dec 2002 18:09:57 -0000
@@ -31,7 +31,6 @@
 void attitude_advisor_choose_tech(struct player *pplayer, 
                                  struct ai_choice *choice)
 {
-  choice->choice = A_NONE;
-  choice->want   = 0;
   /* this function haven't been implemented yet */
+  init_choice(choice);
 }
Index: ai/advdomestic.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdomestic.c,v
retrieving revision 1.95
diff -u -r1.95 advdomestic.c
--- ai/advdomestic.c    25 Nov 2002 19:18:08 -0000      1.95
+++ ai/advdomestic.c    9 Dec 2002 18:09:57 -0000
@@ -1008,7 +1008,8 @@
 
   {
     struct ai_choice cur;
-    
+
+    init_choice(&cur);
     ai_advisor_choose_building(pcity, &cur);
     /* Allowing buy of peaceful units after much testing. -- Syela */
     /* want > 100 means BUY RIGHT NOW */
Index: ai/advforeign.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advforeign.c,v
retrieving revision 1.5
diff -u -r1.5 advforeign.c
--- ai/advforeign.c     14 Nov 2002 09:14:49 -0000      1.5
+++ ai/advforeign.c     9 Dec 2002 18:09:57 -0000
@@ -31,7 +31,6 @@
 void foreign_advisor_choose_tech(struct player *pplayer, 
                                 struct ai_choice *choice)
 {
-  choice->choice = A_NONE;
-  choice->want   = 0;
   /* this function haven't been implemented yet */
+  init_choice(choice);
 }
Index: ai/advmilitary.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advmilitary.c,v
retrieving revision 1.122
diff -u -r1.122 advmilitary.c
--- ai/advmilitary.c    25 Nov 2002 19:18:08 -0000      1.122
+++ ai/advmilitary.c    9 Dec 2002 18:09:58 -0000
@@ -50,9 +50,8 @@
 void military_advisor_choose_tech(struct player *pplayer,
                                  struct ai_choice *choice)
 {
-  choice->choice = A_NONE;
-  choice->want   = 0;
   /* This function hasn't been implemented yet. */
+  init_choice(choice);
 }
 
 /**************************************************************************
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.129
diff -u -r1.129 aicity.c
--- ai/aicity.c 19 Nov 2002 13:31:07 -0000      1.129
+++ ai/aicity.c 9 Dec 2002 18:09:58 -0000
@@ -149,6 +149,7 @@
   struct ai_choice bestchoice, curchoice;
 
   init_choice(&bestchoice);
+  init_choice(&curchoice);
 
   if( is_barbarian(pplayer) ) {    /* always build best attack unit */
     Unit_Type_id i, iunit, bestunit = -1;
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.154
diff -u -r1.154 settlers.c
--- server/settlers.c   4 Dec 2002 13:34:27 -0000       1.154
+++ server/settlers.c   9 Dec 2002 18:09:59 -0000
@@ -1537,7 +1537,7 @@
   struct player *pplayer = city_owner(pcity);
   struct unit virtualunit;
   int want;
-  int gx, gy;
+  int gx = 0, gy = 0;
   struct unit *ferryboat = NULL; /* dummy */
 
   memset(&virtualunit, 0, sizeof(struct unit));

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