#696085 eglibc: memory leak in failed clnt_create call

#696085#5
Date:
2012-12-16 16:02:19 UTC
From:
To:
Hi,

there appears to be a memory leak in the RPC implementation: if a
connection to the portmapper fails, a NULL pointer is returned from
clnt_create to indicate failure (so the caller has no handle), but a chunk
of memory allocated inside the call is never freed:

==14600== 40 bytes in 1 blocks are still reachable in loss record 1 of 1
==14600==    at 0x4C28BED: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14600==    by 0x4C28D6F: realloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14600==    by 0x4F2C795: bindresvport (bindrsvprt.c:102)
==14600==    by 0x4F2DAC9: clnttcp_create (clnt_tcp.c:152)
==14600==    by 0x4F2F60A: __libc_rpc_getport (pm_getport.c:110)
==14600==    by 0x4F2DA8B: clnttcp_create (clnt_tcp.c:137)
==14600==    by 0x4F2CAB3: clnt_create (clnt_gen.c:151)
==14600==    by 0x40052C: main (in /home/geier/test)

Test program attached.

   Simon