diff options
author | ngie <ngie@FreeBSD.org> | 2016-06-08 13:58:47 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2016-06-08 13:58:47 +0000 |
commit | 4d9deb28d571e6b89bd3fc5310ab1aa153baa237 (patch) | |
tree | 679869299daa64600683a1ef36b6dc4a8c980568 /lib | |
parent | 1e9eae959ce6f13ac755c2da7b1631ee5578b6d7 (diff) | |
download | FreeBSD-src-4d9deb28d571e6b89bd3fc5310ab1aa153baa237.zip FreeBSD-src-4d9deb28d571e6b89bd3fc5310ab1aa153baa237.tar.gz |
MFC r300620,r300621:
r300620:
Use reallocf instead of malloc to fix leak with outbuf_pmap
The previous code overwrote outbuf_pmap's memory with malloc once per
loop iteration, which leaked its memory; use reallocf instead to ensure
that memory is properly free'd each loop iteration.
Add a outbuf_pmap = NULL in the failure case to avoid a double-free
at the bottom of the function.
CID: 1038776
r300621:
Remove redundant NULLing of outbuf_pmap
If reallocf ever failed, outbuf_pmap would already be NULL
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libc/rpc/clnt_bcast.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libc/rpc/clnt_bcast.c b/lib/libc/rpc/clnt_bcast.c index 5f78dce..15b48dde 100644 --- a/lib/libc/rpc/clnt_bcast.c +++ b/lib/libc/rpc/clnt_bcast.c @@ -341,7 +341,8 @@ rpc_broadcast_exp(prog, vers, proc, xargs, argsp, xresults, resultsp, #ifdef PORTMAP if (si.si_af == AF_INET && si.si_proto == IPPROTO_UDP) { udpbufsz = fdlist[fdlistno].dsize; - if ((outbuf_pmap = malloc(udpbufsz)) == NULL) { + outbuf_pmap = reallocf(outbuf_pmap, udpbufsz); + if (outbuf_pmap == NULL) { _close(fd); stat = RPC_SYSTEMERROR; goto done_broad; |