[patch] check the return value of nmwa_get_instance()



While playing with my own set of debian packages for NetworkManager
(forgetting to package the glade file), I ran across the following
small problem. In gnome/applet/applet.c, nmwa_get_instance can return
null (and does when the glade file is missing), but its return value
is passed without checking to gtk_widget_show(). This caused the
applet to segfault before the error message about the glade file could
be displayed.


Index: gnome/applet/applet.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.c,v
retrieving revision 1.54
diff -u -r1.54 applet.c
--- gnome/applet/applet.c	12 Sep 2005 17:44:44 -0000	1.54
+++ gnome/applet/applet.c	15 Sep 2005 17:36:04 -0000
@@ -124,6 +124,8 @@
 
 static void nmwa_init (NMWirelessApplet *applet)
 {
+	GtkWidget *widget = NULL;
+
 	applet->animation_id = 0;
 	applet->animation_step = 0;
 	glade_gnome_init ();
@@ -133,7 +135,10 @@
 		return;
 
 /*	gtk_window_set_default_icon_from_file
(ICONDIR"/NMWirelessApplet/wireless-applet.png", NULL); */
-	gtk_widget_show (nmwa_get_instance (applet));
+	widget = nmwa_get_instance (applet);
+	if (!widget)
+		return;
+	gtk_widget_show (widget);
 }
 
 static void nmwa_class_init (NMWirelessAppletClass *klass)


-- 
Will Dyson
Index: gnome/applet/applet.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.c,v
retrieving revision 1.54
diff -u -r1.54 applet.c
--- gnome/applet/applet.c	12 Sep 2005 17:44:44 -0000	1.54
+++ gnome/applet/applet.c	15 Sep 2005 17:36:04 -0000
@@ -124,6 +124,8 @@
 
 static void nmwa_init (NMWirelessApplet *applet)
 {
+	GtkWidget *widget = NULL;
+
 	applet->animation_id = 0;
 	applet->animation_step = 0;
 	glade_gnome_init ();
@@ -133,7 +135,10 @@
 		return;
 
 /*	gtk_window_set_default_icon_from_file (ICONDIR"/NMWirelessApplet/wireless-applet.png", NULL); */
-	gtk_widget_show (nmwa_get_instance (applet));
+	widget = nmwa_get_instance (applet);
+	if (!widget)
+		return;
+	gtk_widget_show (widget);
 }
 
 static void nmwa_class_init (NMWirelessAppletClass *klass)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]