svn commit: r264422 - head/sys/kern
Konstantin Belousov
kostikbel at gmail.com
Sun Apr 13 21:46:39 UTC 2014
On Sun, Apr 13, 2014 at 09:23:16PM +0000, Christian Brueffer wrote:
> Author: brueffer
> Date: Sun Apr 13 21:23:15 2014
> New Revision: 264422
> URL: http://svnweb.freebsd.org/changeset/base/264422
>
> Log:
> Free buf after usage.
>
> CID: 1199377
> Found with: Coverity Prevent(tm)
> MFC after: 1 week
>
> Modified:
> head/sys/kern/imgact_elf.c
>
> Modified: head/sys/kern/imgact_elf.c
> ==============================================================================
> --- head/sys/kern/imgact_elf.c Sun Apr 13 21:13:33 2014 (r264421)
> +++ head/sys/kern/imgact_elf.c Sun Apr 13 21:23:15 2014 (r264422)
> @@ -1746,8 +1746,10 @@ __elfN(note_threadmd)(void *arg, struct
> size = 0;
> __elfN(dump_thread)(td, buf, &size);
> KASSERT(*sizep == size, ("invalid size"));
> - if (size != 0 && sb != NULL)
> + if (size != 0 && sb != NULL) {
> sbuf_bcat(sb, buf, size);
> + free(buf, M_TEMP);
> + }
> *sizep = size;
> }
>
Why conditioning free() on size != 0 ?
IMO free(buf) must be done always, since buf is initialized for the case
when malloc() is not called.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20140414/15034272/attachment.sig>
More information about the svn-src-all
mailing list