gnome 1.4 bonobo memory leak fixes



The attached patch fixes memory leakage caused by using
bonobo_exception_get_text() as if it returned a const char * by using
another variable to hold the value until we are done with it and then
free()'s it. Pretty simple.

I'll probably be submitting another (more serious) leak fix next week
sometime. bonobo-ui-sync-menu.c seems to be leaking pixmap widgets and I
have some ideas on how to fix it but don't feel like testing them
tonight as it would mean messing around with libtool on a solaris box
and I'm just not up for it tonight :-)

Anyways, is it ok to commit this patch?

Jeff

-- 
Jeffrey Stedfast
Evolution Hacker - Ximian, Inc.
fejj ximian com  - www.ximian.com
? bonobo-leak-fixes.patch
? bonobo-ui-sync-menu.c
? doc/api/bonobo-symbols.txt
? doc/api/bonobo-undocumented.txt
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/bonobo/ChangeLog,v
retrieving revision 1.1172
diff -u -r1.1172 ChangeLog
--- ChangeLog	15 May 2002 14:19:42 -0000	1.1172
+++ ChangeLog	1 Jun 2002 00:18:12 -0000
@@ -1,3 +1,34 @@
+2002-05-31  Jeffrey Stedfast  <fejj ximian com>
+
+	* bonobo/bonobo-ui-component.c (impl_xml_set):
+	bonobo_exception_get_text returns a malloc'd string, so we must
+	free it after use.
+	(impl_xml_get): Same.
+	(impl_xml_rm): Here too.
+	(bonobo_ui_component_object_set): And here.
+	(bonobo_ui_component_object_get): "
+	(impl_freeze): "
+	(impl_thaw): "
+	(bonobo_ui_component_unset_container): "
+	(bonobo_ui_component_set_container): And finally here.
+
+	* bonobo/bonobo-control-frame.c
+	(bonobo_control_frame_sync_realize): More leak fixes for
+	bonobo_exception_get_text.
+	(bonobo_control_frame_sync_unrealize): "
+	(bonobo_control_frame_focus_child): "
+
+	* bonobo/bonobo-event-source.c
+	(bonobo_event_source_client_remove_listener): Here too.
+	(bonobo_event_source_client_add_listener): And here.
+
+	* bonobo/bonobo-storage.c (bonobo_storage_open_full): Same.
+
+	* bonobo/bonobo-stream.c (bonobo_stream_open_full): Here too.
+
+	* bonobo/bonobo-transient.c (bonobo_transient_construct): Again...
+	(bonobo_transient_construct): And again...
+
 2002-05-15  Michael Meeks  <michael ximian com>
 
 	* bonobo/bonobo-ui-util.c (bonobo_help_file_find_file):
Index: bonobo/bonobo-control-frame.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-control-frame.c,v
retrieving revision 1.65
diff -u -r1.65 bonobo-control-frame.c
--- bonobo/bonobo-control-frame.c	11 Apr 2002 15:18:56 -0000	1.65
+++ bonobo/bonobo-control-frame.c	1 Jun 2002 00:18:12 -0000
@@ -933,9 +933,13 @@
 	Bonobo_Control_realize (control, &ev);
 
 #ifdef BONOBO_CONTROL_FRAME_DEBUG
-	if (BONOBO_EX (&ev))
-		g_warning ("Exception on realize '%s'",
-			   bonobo_exception_get_text (&ev));
+	if (BONOBO_EX (&ev)) {
+		char *text;
+		
+		text = bonobo_exception_get_text (&ev);
+		g_warning ("Exception on realize '%s'", text);
+		g_free (text);
+	}
 #endif
 
 	CORBA_exception_free (&ev);
@@ -963,9 +967,13 @@
 
 	Bonobo_Control_unrealize (control, &ev);
 #ifdef BONOBO_CONTROL_FRAME_DEBUG
-	if (BONOBO_EX (&ev))
-		g_warning ("Exception on unrealize '%s'",
-			   bonobo_exception_get_text (&ev));
+	if (BONOBO_EX (&ev)) {
+		char *text;
+		
+		text = bonobo_exception_get_text (&ev);
+		g_warning ("Exception on unrealize '%s'", text);
+		g_free (text);
+	}
 #endif
 
 	CORBA_exception_free (&ev);
@@ -1035,8 +1043,12 @@
 
 	result = Bonobo_Control_focusChild (priv->control, corba_direction, &ev);
 	if (BONOBO_EX (&ev)) {
+		char *text;
+		
+		text = bonobo_exception_get_text (&ev);
 		g_message ("bonobo_control_frame_focus_child(): Exception while issuing focusChild "
-			   "request: `%s'", bonobo_exception_get_text (&ev));
+			   "request: `%s'", text);
+		g_free (text);
 		result = FALSE;
 	}
 
Index: bonobo/bonobo-event-source.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-event-source.c,v
retrieving revision 1.29
diff -u -r1.29 bonobo-event-source.c
--- bonobo/bonobo-event-source.c	10 Sep 2001 14:12:57 -0000	1.29
+++ bonobo/bonobo-event-source.c	1 Jun 2002 00:18:12 -0000
@@ -364,9 +364,14 @@
  remove_listener_end:
 
 	if (!opt_ev) {
-		if (BONOBO_EX (my_ev))
-			g_warning ("remove_listener failed '%s'",
-				   bonobo_exception_get_text (my_ev));
+		if (BONOBO_EX (my_ev)) {
+			char *text;
+			
+			text = bonobo_exception_get_text (my_ev);
+			g_warning ("remove_listener failed '%s'", text);
+			g_free (text);
+		}
+		
 		CORBA_exception_free (&ev);
 	}
 }
@@ -432,9 +437,14 @@
  add_listener_end:
 
 	if (!opt_ev) {
-		if (BONOBO_EX (my_ev))
-			g_warning ("add_listener failed '%s'",
-				   bonobo_exception_get_text (my_ev));
+		if (BONOBO_EX (my_ev)) {
+			char *text;
+			
+			text = bonobo_exception_get_text (my_ev);
+			g_warning ("add_listener failed '%s'", text);
+			g_free (text);
+		}
+		
 		CORBA_exception_free (&ev);
 	}
 
Index: bonobo/bonobo-storage.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-storage.c,v
retrieving revision 1.53
diff -u -r1.53 bonobo-storage.c
--- bonobo/bonobo-storage.c	24 May 2001 08:40:07 -0000	1.53
+++ bonobo/bonobo-storage.c	1 Jun 2002 00:18:12 -0000
@@ -216,9 +216,14 @@
 		storage = p->storage_open (path, flags, mode, my_ev);
 
 	if (!opt_ev) {
-		if (BONOBO_EX (my_ev))
-			g_warning ("bonobo_storage_open failed '%s'",
-				   bonobo_exception_get_text (my_ev));
+		if (BONOBO_EX (my_ev)) {
+			char *text;
+			
+			text = bonobo_exception_get_text (my_ev);
+			g_warning ("bonobo_storage_open failed '%s'", text);
+			g_free (text);
+		}
+		
 		CORBA_exception_free (&ev);
 	}
 
Index: bonobo/bonobo-stream.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-stream.c,v
retrieving revision 1.32
diff -u -r1.32 bonobo-stream.c
--- bonobo/bonobo-stream.c	2 May 2001 19:17:28 -0000	1.32
+++ bonobo/bonobo-stream.c	1 Jun 2002 00:18:12 -0000
@@ -224,9 +224,14 @@
 		stream = p->stream_open (path, flags, mode, my_ev);
 
 	if (!opt_ev) {
-		if (BONOBO_EX (my_ev))
-			g_warning ("bonobo_stream_open failed '%s'",
-				   bonobo_exception_get_text (my_ev));
+		if (BONOBO_EX (my_ev)) {
+			char *text;
+			
+			text = bonobo_exception_get_text (my_ev);
+			g_warning ("bonobo_stream_open failed '%s'", text);
+			g_free (text);
+		}
+		
 		CORBA_exception_free (&ev);
 	}
 
Index: bonobo/bonobo-transient.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-transient.c,v
retrieving revision 1.14
diff -u -r1.14 bonobo-transient.c
--- bonobo/bonobo-transient.c	22 Feb 2001 18:49:02 -0000	1.14
+++ bonobo/bonobo-transient.c	1 Jun 2002 00:18:12 -0000
@@ -197,7 +197,8 @@
 	CORBA_Environment		 ev;
 	char				*poa_name;
 	gboolean			 success;
-
+	char                            *text;
+	
 	success = FALSE;
 
 	transient->priv->new_servant = new_servant;
@@ -295,9 +296,11 @@
 			&ev);
 	
 	if (BONOBO_EX (&ev)) {
-		g_warning ("Could not create servant retention policy for BonoboTransient POA '%s'",
-			   bonobo_exception_get_text (&ev));
+		text = bonobo_exception_get_text (&ev);
 		CORBA_exception_free (&ev);
+		g_warning ("Could not create servant retention policy for BonoboTransient POA '%s'",
+			   text);
+		g_free (text);
 		goto out;
 	}
 	
@@ -313,9 +316,11 @@
 			&ev);
 	
 	if (BONOBO_EX (&ev)){
-		g_warning ("Could not create threading policy for BonoboTransient POA '%s'",
-			   bonobo_exception_get_text (&ev));
+		text = bonobo_exception_get_text (&ev);
 		CORBA_exception_free (&ev);
+		g_warning ("Could not create threading policy for BonoboTransient POA '%s'",
+			   text);
+		g_free (text);
 		goto out;
 	}
 
@@ -326,9 +331,11 @@
 			&ev);
 
 	if (BONOBO_EX (&ev)){
-		g_warning ("Could not create activation policy for BonoboTransient POA '%s'",
-			   bonobo_exception_get_text (&ev));
+		text = bonobo_exception_get_text (&ev);
 		CORBA_exception_free (&ev);
+		g_warning ("Could not create activation policy for BonoboTransient POA '%s'",
+			   text);
+		g_free (text);
 		goto out;
 	}
 
@@ -343,9 +350,10 @@
 	g_free (poa_name);
 
 	if (BONOBO_EX (&ev)) {
-		g_warning ("BonoboTransient: Could not create BonoboTransient POA '%s'",
-			   bonobo_exception_get_text (&ev));
+		text = bonobo_exception_get_text (&ev);
 		CORBA_exception_free (&ev);
+		g_warning ("BonoboTransient: Could not create BonoboTransient POA '%s'",
+			   text);
 		goto out;
 	}
 	
Index: bonobo/bonobo-ui-component.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-component.c,v
retrieving revision 1.56
diff -u -r1.56 bonobo-ui-component.c
--- bonobo/bonobo-ui-component.c	14 Nov 2001 22:01:01 -0000	1.56
+++ bonobo/bonobo-ui-component.c	1 Jun 2002 00:18:12 -0000
@@ -664,10 +664,15 @@
 	Bonobo_UIContainer_setNode (container, path, xml,
 				    name, real_ev);
 
-	if (BONOBO_EX (real_ev) && !ev)
+	if (BONOBO_EX (real_ev) && !ev) {
+		char *text;
+		
+		text = bonobo_exception_get_text (real_ev);
 		g_warning ("Serious exception on node_set '$%s' of '%s' to '%s'",
-			   bonobo_exception_get_text (real_ev), xml, path);
-
+			   text, xml, path);
+		g_free (text);
+	}
+	
 	if (!ev)
 		CORBA_exception_free (&tmp_ev);
 }
@@ -782,9 +787,14 @@
 	xml = Bonobo_UIContainer_getNode (container, path, !recurse, real_ev);
 
 	if (BONOBO_EX (real_ev)) {
-		if (!ev)
+		if (!ev) {
+			char *text;
+			
+			text = bonobo_exception_get_text (real_ev);
 			g_warning ("Serious exception getting node '%s' '$%s'",
-				   path, bonobo_exception_get_text (real_ev));
+				   path, text);
+			g_free (text);
+		}
 
 		if (!ev)
 			CORBA_exception_free (&tmp_ev);
@@ -880,9 +890,14 @@
 	Bonobo_UIContainer_removeNode (
 		container, path, priv->name, real_ev);
 
-	if (!ev && BONOBO_EX (real_ev))
+	if (!ev && BONOBO_EX (real_ev)) {
+		char *text;
+		
+		text = bonobo_exception_get_text (real_ev);
 		g_warning ("Serious exception removing path  '%s' '%s'",
-			   path, bonobo_exception_get_text (real_ev));
+			   path, text);
+		g_free (text);
+	}
 
 	if (!ev)
 		CORBA_exception_free (&tmp_ev);
@@ -924,9 +939,14 @@
 
 	Bonobo_UIContainer_setObject (container, path, control, real_ev);
 
-	if (!ev && BONOBO_EX (real_ev))
+	if (!ev && BONOBO_EX (real_ev)) {
+		char *text;
+		
+		text = bonobo_exception_get_text (real_ev);
 		g_warning ("Serious exception setting object '%s' '%s'",
-			   path, bonobo_exception_get_text (real_ev));
+			   path, text);
+		g_free (text);
+	}
 
 	if (!ev)
 		CORBA_exception_free (&tmp_ev);
@@ -970,9 +990,14 @@
 
 	ret = Bonobo_UIContainer_getObject (container, path, real_ev);
 
-	if (!ev && BONOBO_EX (real_ev))
+	if (!ev && BONOBO_EX (real_ev)) {
+		char *text;
+		
+		text = bonobo_exception_get_text (real_ev);
 		g_warning ("Serious exception getting object '%s' '%s'",
-			   path, bonobo_exception_get_text (real_ev));
+			   path, text);
+		g_free (text);
+	}
 
 	if (!ev)
 		CORBA_exception_free (&tmp_ev);
@@ -1066,9 +1091,13 @@
 
 	Bonobo_UIContainer_freeze (container, real_ev);
 
-	if (BONOBO_EX (real_ev) && !ev)
-		g_warning ("Serious exception on UI freeze '$%s'",
-			   bonobo_exception_get_text (real_ev));
+	if (BONOBO_EX (real_ev) && !ev) {
+		char *text;
+		
+		text = bonobo_exception_get_text (real_ev);
+		g_warning ("Serious exception on UI freeze '$%s'", text);
+		g_free (text);
+	}
 
 	if (!ev)
 		CORBA_exception_free (&tmp_ev);
@@ -1114,10 +1143,14 @@
 
 	Bonobo_UIContainer_thaw (container, real_ev);
 
-	if (BONOBO_EX (real_ev) && !ev)
-		g_warning ("Serious exception on UI thaw '$%s'",
-			   bonobo_exception_get_text (real_ev));
-
+	if (BONOBO_EX (real_ev) && !ev) {
+		char *text;
+		
+		text = bonobo_exception_get_text (real_ev);
+		g_warning ("Serious exception on UI thaw '$%s'", text);
+		g_free (text);
+	}
+	
 	if (!ev)
 		CORBA_exception_free (&tmp_ev);
 }
@@ -1305,9 +1338,13 @@
 
 	if (BONOBO_EX (real_ev)) {
 		ret = FALSE;
-		if (!ev)
-			g_warning ("Serious exception on path_exists '$%s'",
-				   bonobo_exception_get_text (real_ev));
+		if (!ev) {
+			char *text;
+			
+			text = bonobo_exception_get_text (real_ev);
+			g_warning ("Serious exception on path_exists '$%s'", text);
+			g_free (text);
+		}
 	}
 
 	if (!ev)
@@ -1379,10 +1416,14 @@
 		Bonobo_UIContainer_removeNode (container, "/", name, &ev);
 		Bonobo_UIContainer_deregisterComponent (container, name, &ev);
 		
-		if (BONOBO_EX (&ev))
-			g_warning ("Serious exception deregistering component '%s'",
-				   bonobo_exception_get_text (&ev));
-
+		if (BONOBO_EX (&ev)) {
+			char *text;
+			
+			text = bonobo_exception_get_text (&ev);
+			g_warning ("Serious exception deregistering component '%s'", text);
+			g_free (text);
+		}
+		
 		CORBA_exception_free (&ev);
 
 		bonobo_object_release_unref (container, NULL);
@@ -1427,9 +1468,13 @@
 		Bonobo_UIContainer_registerComponent (
 			ref_cont, name, corba_component, &ev);
 
-		if (BONOBO_EX (&ev))
-			g_warning ("Serious exception registering component '$%s'",
-				   bonobo_exception_get_text (&ev));
+		if (BONOBO_EX (&ev)) {
+			char *text;
+			
+			text = bonobo_exception_get_text (&ev);
+			g_warning ("Serious exception registering component '$%s'", text);
+			g_free (text);
+		}
 		
 		CORBA_exception_free (&ev);
 	} else


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