Re: [PATCH] gdialog core dumps



On Wed, 24 Mar 1999 17:38:40 Elliot Lee wrote:
> On Wed, 24 Mar 1999 15:27:07 -0500, Jesse D . Sightler <jsight@pair.com> wrote:
> 
> >? gdialog.patch
> >Index: util.c
> >===================================================================
> >RCS file: /cvs/gnome/gnome-utils/gdialog/util.c,v
> >retrieving revision 1.4
> >diff -u -r1.4 util.c
> >--- util.c	1999/01/07 18:27:59	1.4
> >+++ util.c	1999/03/24 20:27:25
> >@@ -367,8 +367,10 @@
> > 		else
> > 			pspace=1;
> > 	}
> >-	g_free((gpointer)input); /* allocated by unquote_nl() */
> >-
> >+	if (!input)
> >+	{
> >+		g_free((gpointer)input); /* allocated by unquote_nl() */
> >+	}
> 
> Since g_free() does not do anything if the pointer passed in is NULL, this
> patch effectively make freeing never get done.
> 
> Doesn't make sense...

That's cause I'm an idiot.  :-)

No, seriously, the reason it doesn't make since is because my previous patch
doesn't really FIX the problem, it just get around it.  The problem is that
the address of input is being passed to g_free, when really the address that
input POINTS TO should be sent to g_free.  Here's a patch that fixes it
the RIGHT way (IMO).

Thanks for pointing this out.  Oh, and the old patch will still work if you've
already applied it.  This one is just cleaner, as it eliminates a usually very
minor memory leak and a bit of inane code.  :)

---------------
Jesse D. Sightler
http://www3.pair.com/jsight/

"An honest answer can get you into a lot of trouble." 
         - Anonymous
Index: util.c
===================================================================
RCS file: /cvs/gnome/gnome-utils/gdialog/util.c,v
retrieving revision 1.4
diff -u -r1.4 util.c
--- util.c	1999/01/07 18:27:59	1.4
+++ util.c	1999/03/25 03:06:57
@@ -367,7 +367,7 @@
 		else
 			pspace=1;
 	}
-	g_free((gpointer)input); /* allocated by unquote_nl() */
+	g_free((gpointer)(*input)); /* allocated by unquote_nl() */
 
 	if(blen)
 	{


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