This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [commit] Compilation regression [Re: [RFA] Fix memory leak in gdbserver/hostio.c]
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: jan dot kratochvil at redhat dot com (Jan Kratochvil)
- Cc: msnyder at vmware dot com (Michael Snyder), pedro at codesourcery dot com (Pedro Alves), gdb-patches at sourceware dot org (gdb-patches at sourceware dot org), drow at false dot org (drow at false dot org)
- Date: Mon, 28 Feb 2011 16:57:33 +0100 (CET)
- Subject: Re: [commit] Compilation regression [Re: [RFA] Fix memory leak in gdbserver/hostio.c]
Jan Kratochvil wrote:
> On Sun, 27 Feb 2011 22:50:11 +0100, Michael Snyder wrote:
> > 2011-02-27 Michael Snyder <msnyder@vmware.com>
> >
> > * hostio.c (require_data): Free malloc memory before returning
> > error.
> >
> > --- hostio.c 1 Jan 2011 15:33:24 -0000 1.11
> > +++ hostio.c 27 Feb 2011 21:48:00 -0000
> > @@ -134,7 +134,10 @@ require_data (char *p, int p_len, char *
> > + xfree (data);
>
> = http://sourceware.org/ml/gdb-cvs/2011-02/msg00220.html
>
> hostio.c: In function ‘require_data’:
> hostio.c:138:7: error: implicit declaration of function ‘xfree’ [-Werror=implicit-function-declaration]
> cc1: all warnings being treated as errors
> make: *** [hostio.o] Error 1
>
> It could not build as -Werror is there by default, could it?
>
> Checked in the fix.
Actually, this is still broken:
/home/uweigand/fsf/gdb-head/gdb/gdbserver/hostio.c:138: error: attempt to free a non-heap object 'data'
The allocated object is *data, not data (data is of type char ** here).
Checked in the following fix.
Bye,
Ulrich
ChangeLog:
* hostio.c (require_data): Free *data, not data.
Index: gdb/gdbserver/hostio.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/hostio.c,v
retrieving revision 1.13
diff -u -p -r1.13 hostio.c
--- gdb/gdbserver/hostio.c 28 Feb 2011 04:20:30 -0000 1.13
+++ gdb/gdbserver/hostio.c 28 Feb 2011 15:38:59 -0000
@@ -135,7 +135,7 @@ require_data (char *p, int p_len, char *
if (escaped)
{
- free (data);
+ free (*data);
return -1;
}
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com