Author: cazfi
Date: Sun Feb  8 07:12:17 2015
New Revision: 28032

URL: http://svn.gna.org/viewcvs/freeciv?rev=28032&view=rev
Log:
Fixed an illegal array index usage in AI building effect value adjustments
when handling an city on ocean.

See bug #23230

Modified:
    branches/S2_4/ai/default/aicity.c
    branches/S2_4/client/gui-gtk-2.0/cma_fe.c
    branches/S2_4/client/gui-gtk-3.0/cma_fe.c

Modified: branches/S2_4/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/ai/default/aicity.c?rev=28032&r1=28031&r2=28032&view=diff
==============================================================================
--- branches/S2_4/ai/default/aicity.c   (original)
+++ branches/S2_4/ai/default/aicity.c   Sun Feb  8 07:12:17 2015
@@ -1728,6 +1728,7 @@
     .value = {.building = pimprove}
   };
   const bool is_coinage = improvement_has_flag(pimprove, IF_GOLD);
+  int place = tile_continent(pcity->tile);
 
   /* Remove team members from the equation */
   players_iterate(aplayer) {
@@ -1768,7 +1769,11 @@
   cities[REQ_RANGE_PLAYER] = city_list_size(pplayer->cities);
   cities[REQ_RANGE_WORLD] = cities[REQ_RANGE_PLAYER]; /* kludge. */
 
-  cities[REQ_RANGE_CONTINENT] = ai->stats.cities[tile_continent(pcity->tile)];
+  if (place < 0) {
+    cities[REQ_RANGE_CONTINENT] = 1;
+  } else {
+    cities[REQ_RANGE_CONTINENT] = ai->stats.cities[place];
+  }
 
   cities[REQ_RANGE_CITY] = cities[REQ_RANGE_LOCAL] = 1;
 

Modified: branches/S2_4/client/gui-gtk-2.0/cma_fe.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/client/gui-gtk-2.0/cma_fe.c?rev=28032&r1=28031&r2=28032&view=diff
==============================================================================
--- branches/S2_4/client/gui-gtk-2.0/cma_fe.c   (original)
+++ branches/S2_4/client/gui-gtk-2.0/cma_fe.c   Sun Feb  8 07:12:17 2015
@@ -177,12 +177,16 @@
                           GtkTreeModel *model, GtkTreeIter *it, gpointer data)
 {
   struct cma_dialog *pdialog = (struct cma_dialog *) data;
-  const char *s1, *s2;
+  char *s1;
+  const char *s2;
   int i1, i2;
   struct cm_parameter param;
   GtkTreePath *path;
 
-  gtk_tree_model_get(model, it, 0, &s1, -1); 
+  gtk_tree_model_get(model, it, 0, &s1, -1);
+  if (s1 == NULL) {
+    return;
+  }
   path = gtk_tree_model_get_path(model, it);
   i1 = gtk_tree_path_get_indices(path) [0];
   gtk_tree_path_free(path);
@@ -198,6 +202,8 @@
     g_object_set(G_OBJECT(cell), "style", PANGO_STYLE_NORMAL,
                 "weight", PANGO_WEIGHT_NORMAL, NULL);
   }
+
+  free(s1);
 }
 
 /**************************************************************************

Modified: branches/S2_4/client/gui-gtk-3.0/cma_fe.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_4/client/gui-gtk-3.0/cma_fe.c?rev=28032&r1=28031&r2=28032&view=diff
==============================================================================
--- branches/S2_4/client/gui-gtk-3.0/cma_fe.c   (original)
+++ branches/S2_4/client/gui-gtk-3.0/cma_fe.c   Sun Feb  8 07:12:17 2015
@@ -177,12 +177,16 @@
                           GtkTreeModel *model, GtkTreeIter *it, gpointer data)
 {
   struct cma_dialog *pdialog = (struct cma_dialog *) data;
-  const char *s1, *s2;
+  char *s1;
+  const char *s2;
   int i1, i2;
   struct cm_parameter param;
   GtkTreePath *path;
 
-  gtk_tree_model_get(model, it, 0, &s1, -1); 
+  gtk_tree_model_get(model, it, 0, &s1, -1);
+  if (s1 == NULL) {
+    return;
+  }
   path = gtk_tree_model_get_path(model, it);
   i1 = gtk_tree_path_get_indices(path) [0];
   gtk_tree_path_free(path);
@@ -198,6 +202,8 @@
     g_object_set(G_OBJECT(cell), "style", PANGO_STYLE_NORMAL,
                 "weight", PANGO_WEIGHT_NORMAL, NULL);
   }
+
+  free(s1);
 }
 
 /**************************************************************************


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to