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: [RFA] Fix memory leak in gdbserver/hostio.c


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


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