Author: cazfi
Date: Sun Feb  8 06:30:16 2015
New Revision: 28020

URL: http://svn.gna.org/viewcvs/freeciv?rev=28020&view=rev
Log:
Fixed a crash in construction of citydlg governor -tab. Also fixes a minor 
memory leak.
The crash was ever encountered in gtk3-client only, but the fix is made to both 
gtk-clients.

Reported by David Fernandez <bardo> and amie78

See bug #21942

Modified:
    trunk/client/gui-gtk-2.0/cma_fe.c
    trunk/client/gui-gtk-3.0/cma_fe.c

Modified: trunk/client/gui-gtk-2.0/cma_fe.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-2.0/cma_fe.c?rev=28020&r1=28019&r2=28020&view=diff
==============================================================================
--- trunk/client/gui-gtk-2.0/cma_fe.c   (original)
+++ trunk/client/gui-gtk-2.0/cma_fe.c   Sun Feb  8 06:30:16 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: trunk/client/gui-gtk-3.0/cma_fe.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-gtk-3.0/cma_fe.c?rev=28020&r1=28019&r2=28020&view=diff
==============================================================================
--- trunk/client/gui-gtk-3.0/cma_fe.c   (original)
+++ trunk/client/gui-gtk-3.0/cma_fe.c   Sun Feb  8 06:30:16 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