psppire-window-base: Avoid memory leak in get_window_id(). 20120710000508/pspp
authorBen Pfaff <blp@cs.stanford.edu>
Tue, 10 Jul 2012 04:54:39 +0000 (21:54 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Tue, 10 Jul 2012 04:56:11 +0000 (21:56 -0700)
g_object_get() returns a string copy, so the caller has to free it,
but gtk_widget_get_name() gets the same string without a copy.

Found by valgrind.

src/ui/gui/psppire-window-base.c

index 29c0fd7a5851e6119b12b52ad3c6d227b72ab63d..a9f73535dfd460b534f05bcf7cacb0063526f4cb 100644 (file)
@@ -46,10 +46,7 @@ G_DEFINE_ABSTRACT_TYPE (PsppireWindowBase, psppire_window_base, GTK_TYPE_WINDOW)
 static const char *
 get_window_id (GtkWidget *wb)
 {
-  const gchar *name = NULL;
-      
-  g_object_get (wb, "name", &name, NULL);
-
+  const gchar *name = gtk_widget_get_name (wb);
   if (NULL == name || 0 == strcmp ("", name))
     name = G_OBJECT_TYPE_NAME (wb);