This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]