Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2005:
[Freeciv-Dev] (PR#13527) fix AI log crash
Home

[Freeciv-Dev] (PR#13527) fix AI log crash

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#13527) fix AI log crash
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 24 Jul 2005 11:22:18 -0700
Reply-to: bugs@xxxxxxxxxxx

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

The attached patch avoids a crash in the AI log code.
get_improvement_name is called on the value of 199 which is an illegal
dereference.

Interestingly the "best" struct has 199 as its choice field, with
best->type as CT_BUILDING.  I assume this is used as an intentionally
invalid value.  However this is wrong because 199 could be valid if
there were 200 buildings (the maximum).

-jason

Index: ai/aitools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aitools.c,v
retrieving revision 1.157
diff -p -u -r1.157 aitools.c
--- ai/aitools.c        23 Jul 2005 18:02:43 -0000      1.157
+++ ai/aitools.c        24 Jul 2005 18:19:43 -0000
@@ -1112,6 +1112,7 @@ void adjust_choice(int value, struct ai_
 void copy_if_better_choice(struct ai_choice *cur, struct ai_choice *best)
 {
   if (cur->want > best->want) {
+#if 0
     freelog(LOG_DEBUG, "Overriding choice (%s, %d) with (%s, %d)",
            (best->type == CT_BUILDING
             ?  get_improvement_name(best->choice)
@@ -1121,6 +1122,7 @@ void copy_if_better_choice(struct ai_cho
             ? get_improvement_name(cur->choice)
             : get_unit_type(cur->choice)->name), 
            cur->want);
+#endif
     best->choice =cur->choice;
     best->want = cur->want;
     best->type = cur->type;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#13527) fix AI log crash, Jason Short <=