[RFA] Fix memory leak in gdbserver/hostio.c
Michael Snyder
msnyder@vmware.com
Sun Feb 27 21:57:00 GMT 2011
Pedro Alves wrote:
> 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.
Like this?
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hostio2.txt
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20110227/dc200aac/attachment.txt>
More information about the Gdb-patches
mailing list