This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Fix memory leak in gdbserver/hostio.c
- From: Pedro Alves <pedro at codesourcery dot com>
- To: gdb-patches at sourceware dot org
- Cc: Michael Snyder <msnyder at vmware dot com>, "drow at false dot org" <drow at false dot org>
- Date: Sun, 27 Feb 2011 17:05:43 +0000
- Subject: Re: [RFA] Fix memory leak in gdbserver/hostio.c
- References: <4D699B2E.3020107@vmware.com>
On Sunday 27 February 2011 00:30:38, Michael Snyder wrote:
> Found by coverity.
Do you try running coverity on your patches?
> @@ -367,6 +367,7 @@ handle_pwrite (char *own_buf, int packet
> || require_data (p, packet_len - (p - own_buf), &data, &len))
> {
> hostio_packet_error (own_buf);
> + free (data);
> return;
> }
This is wrong. If any predicate other than require_data in if above
returned true, then you'll be freeing a garbage pointer. I'd
fix this in require_data ... just free the output buffer when
returning error, so the callers never have to.
--
Pedro Alves