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
This commit is contained in:
parent
9c759b587f
commit
75cd48a1c1
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user