Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2002:
[Freeciv-Dev] Re: (PR#2666) uninitialized read in aidiplomat
Home

[Freeciv-Dev] Re: (PR#2666) uninitialized read in aidiplomat

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#2666) uninitialized read in aidiplomat
From: "Per I. Mathisen via RT" <rt@xxxxxxxxxxxxxx>
Date: Sun, 29 Dec 2002 03:59:53 -0800
Reply-to: rt@xxxxxxxxxxxxxx

On Sun, 29 Dec 2002, Jason Short via RT wrote:
> After fixing PR#2665, I run across this warning.
>
> ==17660== Conditional jump or move depends on uninitialised value(s)
> ==17660==  at 0x80C3422: ai_choose_diplomat_offensive
> (aidiplomat.c:160)
> ==17660==  by 0x80B4C45: military_advisor_choose_build
> (advmilitary.c:1476)
> ==17660==  by 0x80B84B0: ai_manage_cities (aicity.c:509)
> ==17660==  by 0x80BA8DC: ai_do_last_activities (aihand.c:66)

Ah, of course. That would be the second part of

    if (acity == NULL || acity->ai.already_considered_for_diplomat) {

we set this variable on beginning of turn, but during this turn we may
have created new cities...

The attached patch fixes the problem. This might be your "AI depends on
contents of raw memory" bug, Mike.

  - Per

Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.201
diff -u -r1.201 citytools.c
--- server/citytools.c  2002/12/18 17:36:19     1.201
+++ server/citytools.c  2002/12/29 11:57:21
@@ -1046,6 +1046,7 @@
   pcity->ai.danger = 0;
   pcity->ai.urgency = 0;
   pcity->ai.grave_danger = 0;
+  pcity->ai.already_considered_for_diplomat = FALSE;
   pcity->corruption = 0;
   pcity->shield_bonus = 100;
   pcity->tax_bonus = 100;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#2666) uninitialized read in aidiplomat, Per I. Mathisen via RT <=