Memory leak in libsmb

Ong Kian Win codegrunt at rubbercookie.com
Tue Feb 26 22:04:05 GMT 2002


Hi!

Unlike the samba daemons, libsmb doesn't seem to free up memory in the
temporary memory pools.

I found 2 places where the temporary pools are used (there should be more)

1.  0x08057E2C (10 bytes) {malloc:389:0} [-|-|-]
        0x400F413A talloc
        0x400F4456 talloc_vasprintf+54
        0x400F40F1 talloc_init_named+49
        0x401213AD lp_string+77
        0x4012148C lp_unix_charset+44
        0x400DC7B1 charset_name+49
        0x400DC8CE init_iconv+158
        0x400DC820 lazy_initialize_conv+48
        0x400DCA52 convert_string+66
        0x400DD1BF push_ucs2+191
        0x400E8D8C strchr_m+60
        0x400EE649 is_ipaddress+105
        0x400EE6DB interpret_addr+107
        0x400EE7FE interpret_addr2+30
        0x400DEE3C load_interfaces+76
        0x400D951F smbc_init+175

2.  0x08109E60 (123 bytes) {malloc:2782:0} [-|-|-]
        0x400F413A talloc
        0x401213C8 lp_string+104
        0x40121ACC lp_name_resolve_order+44
        0x4010E0B0 internal_resolve_name+432
        0x4010E4A1 resolve_name+97
        0x40101710 cli_connect+160
        0x400D8D5C smbc_server+924
        0x400DB71D smbc_opendir+2381

For the memory allocated in lp_string, I think it might be a good idea to
dellocate it in
smbc_remove_unused_server().

My concern is that smbc_init (see above) uses lp_string indirectly as well.
However, since is_ipaddress only returns a BOOL and the strings are not used
directly in smbc_init, I think it should be ok.

Regards,
Kian Win

Samba CVS HEAD, Feb 25 10:09 +0800

--- libsmbclient.c.bkp.1	Wed Feb 27 12:54:32 2002
+++ libsmbclient.c	Wed Feb 27 13:42:46 2002
@@ -436,6 +436,7 @@
 	DLIST_REMOVE(smbc_srvs, s);
 	DEBUG(3, ("smbc_remove_usused_server: %x removed.\n", (int) s));
 	SAFE_FREE(s);
+	lp_talloc_free();
 	return True;
 }





More information about the samba-technical mailing list