[Date Prev][Date Next] [Chronological] [Thread] [Top]

(ITS#9081) Memory leak in ldap_initialize/ldap_unbind



Full_Name: Jan Engelhardt
Version: 2.4.48
OS: openSUSE Tumbleweed; Linux 5.3.0-rc7 x86_64
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (2a02:8108:96c0:15fc:2137:8684:9608:51f8)


» cat x.c 
#define LDAP_DEPRECATED 1
#include <ldap.h>
int main()
{
        LDAP *ld;
        ldap_initialize(&ld, "ldapi:///");
        ldap_unbind(ld);
}

» gcc x.c -Wall -lldap -ggdb3
» valgrind --leak-check=full ./a.out 
==25779== HEAP SUMMARY:
==25779==     in use at exit: 26,395 bytes in 85 blocks
==25779==   total heap usage: 233 allocs, 148 frees, 177,134 bytes allocated
==25779== 
==25779== 40 bytes in 1 blocks are definitely lost in loss record 11 of 24
==25779==    at 0x4838B65: calloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==25779==    by 0x4A8310C: ber_memcalloc_x (memory.c:283)
==25779==    by 0x4A84EC0: ber_sockbuf_alloc (sockbuf.c:60)
==25779==    by 0x487396A: ldap_create (open.c:172)
==25779==    by 0x4873C8D: ldap_initialize (open.c:241)
==25779==    by 0x10915F: main (x.c:6)
==25779== 
==25779== LEAK SUMMARY:
==25779==    definitely lost: 40 bytes in 1 blocks
==25779==    indirectly lost: 0 bytes in 0 blocks
==25779==      possibly lost: 0 bytes in 0 blocks
==25779==    still reachable: 26,355 bytes in 84 blocks
==25779==         suppressed: 0 bytes in 0 blocks
==25779== Reachable blocks (those to which a pointer was found) are not shown.
==25779== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==25779== 
==25779== For lists of detected and suppressed errors, rerun with: -s
==25779== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

unbind.c:
123             for ( lm = ld->ld_responses; lm != NULL; lm = next ) {
128             if ( ld->ld_abandoned != NULL ) {
132             LDAP_MUTEX_UNLOCK( &ld->ld_res_mutex );
136             ber_int_sb_destroy( ld->ld_sb );

Should this probably be LBER_FREE rather than ber_int_sb_destroy?