Re: [PATCH] rpcbind: fix leak of nconf in main()

Steve Dickson <[email protected]>
Newsgroups gmane.linux.nfs
Message-ID <[email protected]>

On 6/30/26 12:13 PM, Scott Mayhew wrote:
> Before reusing nconf in the getnetconfig() loop, we need to free the
> memory that was previously allocated via getnetconfigent().  Fixes the
> following leak reported by valgrind:
> 
> ==9031== 1,136 (136 direct, 1,000 indirect) bytes in 1 blocks are definitely lost in loss record 63 of 67
> ==9031==    at 0x485183E: malloc (vg_replace_malloc.c:447)
> ==9031==    by 0x4879D1F: getnetconfigent (in /usr/lib64/libtirpc.so.3.0.0)
> ==9031==    by 0x4004336: main (rpcbind.c:271)
> 
> Signed-off-by: Scott Mayhew <[email protected]>
Committed...

steved.> ---
>   src/rpcbind.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/src/rpcbind.c b/src/rpcbind.c
> index 4212377..c39df97 100644
> --- a/src/rpcbind.c
> +++ b/src/rpcbind.c
> @@ -282,6 +282,7 @@ main(int argc, char *argv[])
>   	rpc_control(RPC_SVC_CONNMAXREC_SET, &maxrec);
>   
>   	init_transport(nconf);
> +	freenetconfigent(nconf);
>   
>   	while ((nconf = getnetconfig(nc_handle))) {
>   		if (nconf->nc_flag & NC_VISIBLE)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.