ac527ca fix various memory leaks

Authored and Committed by rmeggins 14 years ago
    fix various memory leaks
    
    Reviewed by: nhosoi (Thanks!)
    var/tmp/run_gssapi.vg.25032:Memory leak: 99 bytes duplicates:  5
      > malloc() at vg_replace_malloc.c:207
      > strdup() at /lib/libc-2.10.2.so
      > slapi_ch_strdup() at ch_malloc.c:277
      > ids_sasl_check_bind() at saslbind.c:924
      > do_bind() at bind.c:382
      > connection_threadmain() at connection.c:554
      > --unknown-- at /lib/libnspr4.so
      > start_thread() at /lib/libpthread-2.10.2.so
      > clone() at /lib/libc-2.10.2.so
    The problem is that ids_sasl_check_bind can reset SLAPI_BIND_TARGET to
    a malloc'd value.  The do_bind() code should check for this condition
    and free it.
    
    var/tmp/entryusn.vg.5997:Memory leak: 8 bytes duplicates:  8
      > calloc() at vg_replace_malloc.c:397
      > slapi_ch_calloc() at ch_malloc.c:243
      > slapi_counter_new() at slapi_counter.c:95
      > ldbm_usn_init() at ldbm_usn.c:86
      > ldbm_back_start() at start.c:223
      > plugin_call_func() at plugin.c:1417
      > plugin_dependency_startall.clone.0() at plugin.c:1385
      > main() at main.c:1138
    The backend cleanup code should free be_usn_counter.
    
    var/tmp/ipv6.vg.15561:Memory leak: 13 bytes duplicates:  3
      > malloc() at vg_replace_malloc.c:207
      > strdup() at /lib/libc-2.10.2.so
      > slapi_ch_strdup() at ch_malloc.c:277
      > config_get_listenhost() at libglobs.c:3674
      > main() at main.c:874
    var/tmp/ipv6.vg.15561:Memory leak: 13 bytes duplicates:  3
      > malloc() at vg_replace_malloc.c:207
      > strdup() at /lib/libc-2.10.2.so
      > slapi_ch_strdup() at ch_malloc.c:277
      > config_get_securelistenhost() at libglobs.c:3686
      > main() at main.c:881
    
    config_get_listenhost() and config_get_securelistenhost() return malloc'd
    memory which must be freed.
    
    var/tmp/dna_scen1.vg.4901:Memory leak: 248 bytes duplicates:  1
      > malloc() at vg_replace_malloc.c:207
      > nslberi_malloc() at io.c:1677
      > ber_flatten() at io.c:1604
      > create_NSDS50ReplicationExtopPayload() at repl_extop.c:218
      > NSDS50EndReplicationRequest_new() at repl_extop.c:265
      > release_replica() at repl5_protocol_util.c:469
      > repl5_inc_run() at repl5_inc_protocol.c:1187
      > prot_thread_main() at repl5_protocol.c:341
      > --unknown-- at /lib/libnspr4.so
      > start_thread() at /lib/libpthread-2.10.2.so
      > clone() at /lib/libc-2.10.2.so
    The payload was not being freed under all function exit conditions.  So, just free it immediately after use.
    
    var/tmp/dnarun.vg.2491:Memory leak: 27 bytes duplicates:  0
      > malloc() at vg_replace_malloc.c:207
      > slapi_ch_malloc() at ch_malloc.c:155
      > slapi_entry_attr_get_charptr() at entry.c:2432
      > dna_parse_config_entry() at dna.c:816
      > dna_pre_op() at dna.c:2587
      > plugin_call_func() at plugin.c:1417
      > plugin_call_plugins() at plugin.c:1379
      > op_shared_add() at add.c:606
      > do_add() at add.c:232
      > connection_threadmain() at connection.c:564
      > --unknown-- at /lib/libnspr4.so
      > start_thread() at /lib/libpthread-2.10.2.so
      > clone() at /lib/libc-2.10.2.so
    The value was not being freed under all conditions.
    
    ==9877== 1,890 (252 direct, 1,638 indirect) bytes in 3 blocks are definitely lost in loss record 1,628 of 1,725
    ==9877==    at 0x47E0E5C: calloc (vg_replace_malloc.c:397)
    ==9877==    by 0x4819D89: slapi_ch_calloc (ch_malloc.c:243)
    ==9877==    by 0x48284A6: slapi_entry_alloc (entry.c:1686)
    ==9877==    by 0x4829BA5: str2entry_dupcheck (entry.c:631)
    ==9877==    by 0x482BB5D: slapi_str2entry_ext (entry.c:1194)
    ==9877==    by 0xB2A8E9D: import_producer (import-threads.c:541)
    ==9877==    by 0x72E1990: (within /lib/libnspr4.so)
    ==9877==    by 0x731E8F4: start_thread (in /lib/libpthread-2.10.2.so)
    ==9877==    by 0x75B2FCD: clone (in /lib/libc-2.10.2.so)
    Make sure the entry or backentry are freed.
    (cherry picked from commit 64db7873c668ec17fc92aedc37cbd9f476ded605)
    
        
file modified
+1 -0
file modified
+6 -0
file modified
+9 -2