diff options
author | Enji Cooper <ngie@FreeBSD.org> | 2016-05-24 18:44:50 +0000 |
---|---|---|
committer | Enji Cooper <ngie@FreeBSD.org> | 2016-05-24 18:44:50 +0000 |
commit | 75cd48a1c113ee3b65d5340fae39c5aeeb42a92a (patch) | |
tree | 6e17221d18549fda93232811468568a23c14d6d5 /lib/libc/rpc | |
parent | 9c759b587fd534db889ab766ccfa2d6657c12d1c (diff) | |
download | src-75cd48a1c113ee3b65d5340fae39c5aeeb42a92a.tar.gz src-75cd48a1c113ee3b65d5340fae39c5aeeb42a92a.zip |
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.
Differential Revision: https://reviews.freebsd.org/D6495
MFC after: 1 week
Reported by: Coverity
CID: 1038776
Reviewed by: markj, pfgj
Sponsored by: EMC / Isilon Storage Division
Notes
Notes:
svn path=/head/; revision=300620
Diffstat (limited to 'lib/libc/rpc')
-rw-r--r-- | lib/libc/rpc/clnt_bcast.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libc/rpc/clnt_bcast.c b/lib/libc/rpc/clnt_bcast.c index 99f54082d002..33dc0c84a979 100644 --- a/lib/libc/rpc/clnt_bcast.c +++ b/lib/libc/rpc/clnt_bcast.c @@ -346,7 +346,9 @@ rpc_broadcast_exp(rpcprog_t prog, rpcvers_t vers, rpcproc_t proc, #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) { + outbuf_pmap = NULL; _close(fd); stat = RPC_SYSTEMERROR; goto done_broad; |