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

2008/5/15 [EMAIL PROTECTED] :
>
> server crashes (segmentation fault) after issuing following commands to
> server :
>
> The problem is that following happens:
> 1. pointers in struct ai get freed when "end" command is issued (in
> ai_data_phase_done)  and  ai->threats.continents becomes 0.
> 2. When second "load" is being done, ai_data_get gets called
> 3. But it doesn't call ai_data_phase_init, because ai->num_continents ==
> map.num_continents.
> 4. So ai->threats.continents stays 0.
> 5. Accessing it means segfault.

 Thanks for the report and analysis.

 Fix attached.


 - ML

diff -Nurd -X.diff_ignore freeciv/ai/aidata.c freeciv/ai/aidata.c
--- freeciv/ai/aidata.c	2008-02-02 09:04:25.000000000 +0200
+++ freeciv/ai/aidata.c	2008-05-16 02:18:01.000000000 +0300
@@ -165,7 +165,7 @@
 }
 
 /**************************************************************************
-  Analyze rulesets. Must be run after rulesets after loaded, unlike
+  Analyze rulesets. Must be run after rulesets are loaded, unlike
   _init, which must be run before savegames are loaded, which is usually
   before rulesets.
 **************************************************************************/
@@ -594,6 +594,9 @@
 
   free(ai->channels);
   ai->channels = NULL;
+
+  ai->num_continents = 0;
+  ai->num_oceans     = 0;
 }
 
 /**************************************************************************
diff -Nurd freeciv/ai/aidata.c freeciv/ai/aidata.c
--- freeciv/ai/aidata.c	2008-05-12 01:40:25.000000000 +0300
+++ freeciv/ai/aidata.c	2008-05-15 22:26:33.000000000 +0300
@@ -544,6 +544,9 @@
 
   free(ai->stats.cities);
   ai->stats.cities = NULL;
+
+  ai->num_continents    = 0;
+  ai->num_oceans        = 0;
 }
 
 /**************************************************************************
diff -Nurd freeciv/ai/aidata.c freeciv/ai/aidata.c
--- freeciv/ai/aidata.c	2008-05-03 13:28:54.000000000 +0300
+++ freeciv/ai/aidata.c	2008-05-15 22:59:58.000000000 +0300
@@ -455,6 +455,9 @@
   ai->threats.ocean = NULL;
   free(ai->stats.workers);     ai->stats.workers = NULL;
   free(ai->stats.cities);      ai->stats.cities = NULL;
+
+  ai->num_continents = 0;
+  ai->num_oceans = 0;
 }
 
 /**************************************************************************
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to