[sylpheed:31970] Re: [PATCH] Sylpheed 2.4.7 memory leak in LDAP

Hiroyuki Yamamoto hiro-y at kcn.ne.jp
Mon Dec 17 17:10:34 JST 2007


Hello,

On Tue, 11 Dec 2007 14:35:27 +0100
"Michael Schwendt" <mschwendt at gmail.com> wrote:

> ---------- Forwarded message ----------
> From: Michael Schwendt
> Date: 1 Nov 2007 22:08
> Subject: Re: Sylpheed 2.4.7 segfault in LDAP search
> To: Hiroyuki Yamamoto
> 
> 
> In syldap.c, function syldap_search(), in the  "/* Process all
> attributes */" loop, why is only the last "attribute" pointer freed
> with ldap_memfree() after the loop is done? As I understand it, both
> ldap_first_attribute() and ldap_next_attribute() return a dynamically
> allocated array of char every time (or NULL), which ought to be freed
> after each iteration of the loop. IMO:

You are correct, and there were four more leaks in syldap.c :)
Fixed in svn trunk.

> --- syldap.c~   2006-08-31 10:21:21.000000000 +0200
> +++ syldap.c    2007-11-01 22:05:29.000000000 +0100
> @@ -602,11 +602,10 @@
>                         if( g_ascii_strcasecmp( attribute,
> SYLDAP_ATTR_DN ) == 0 ) {
>                                 listDN = syldap_add_single_value( ld,
> e, attribute );
>                         }
> +                       /* Free memory used to store attribute */
> +                       ldap_memfree( attribute );
>                 }
> 
> -               /* Free memory used to store attribute */
> -               ldap_memfree( attribute );
> -
>                 /* Format and add items to cache */
>                 syldap_build_items_fl( ldapServer, listAddress,
> listFirst, listLast );


-- 
Hiroyuki Yamamoto <hiro-y at kcn.ne.jp>


More information about the Sylpheed mailing list