summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-05-24 18:44:50 +0000
committerngie <ngie@FreeBSD.org>2016-05-24 18:44:50 +0000
commiteba093149c09a994d9a51b286c887c680ec69d8e (patch)
tree6e17221d18549fda93232811468568a23c14d6d5
parent0f36ad80049b08e97edcca587589d43aa0bcb675 (diff)
downloadFreeBSD-src-eba093149c09a994d9a51b286c887c680ec69d8e.zip
FreeBSD-src-eba093149c09a994d9a51b286c887c680ec69d8e.tar.gz
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
-rw-r--r--lib/libc/rpc/clnt_bcast.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libc/rpc/clnt_bcast.c b/lib/libc/rpc/clnt_bcast.c
index 99f5408..33dc0c8 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;
OpenPOWER on IntegriCloud