Date: Wed, 8 Jun 2016 13:58:47 +0000 (UTC) From: Garrett Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r301622 - stable/10/lib/libc/rpc Message-ID: <201606081358.u58Dwlt1048159@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Wed Jun 8 13:58:47 2016 New Revision: 301622 URL: https://svnweb.freebsd.org/changeset/base/301622 Log: 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 Modified: stable/10/lib/libc/rpc/clnt_bcast.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/rpc/clnt_bcast.c ============================================================================== --- stable/10/lib/libc/rpc/clnt_bcast.c Wed Jun 8 13:57:18 2016 (r301621) +++ stable/10/lib/libc/rpc/clnt_bcast.c Wed Jun 8 13:58:47 2016 (r301622) @@ -341,7 +341,8 @@ rpc_broadcast_exp(prog, vers, proc, xarg #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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606081358.u58Dwlt1048159>