Author: cazfi
Date: Sun Feb  8 06:30:33 2015
New Revision: 28022

URL: http://svn.gna.org/viewcvs/freeciv?rev=28022&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:
    branches/S2_5/client/gui-gtk-2.0/cma_fe.c
    branches/S2_5/client/gui-gtk-3.0/cma_fe.c

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