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

(ITS#4064) Memory leak in sasl.c (tls.c as well)



Full_Name: Mike Patnode
Version: 2.2.26
OS: RedHat
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (63.199.144.29)


The exact same code is in tls.c as well without the NULL/free check.   It would
probably be better to have an accessor method/macro which set the value of
ld_error for you, so this problem could be avoided....


--- ./openldap-2.2.26/libraries/libldap/cyrus.c.orig	Tue Oct 04 09:23:31 2005
+++ ./openldap-2.2.26/libraries/libldap/cyrus.c	Tue Oct 04 09:23:04 2005
@@ -703,6 +703,10 @@
         {
             ld->saslint_errno = ctx->error_code_int;
             rc = ld->ld_errno = sasl_err2ldap( saslrc, ld->saslint_errno );
+            if ( ld->ld_error ) {
+                LDAP_FREE( ld->ld_error );
+                ld->ld_error = NULL;
+            }
             ld->ld_error = LDAP_STRDUP( sasl_errdetail( ctx ) );
             goto done;
         }
@@ -713,6 +717,10 @@
     if ( saslrc != SASL_OK ) 
     {
         ld->saslint_errno = ctx->error_code_int;
+        if ( ld->ld_error ) {
+            LDAP_FREE( ld->ld_error );
+            ld->ld_error = NULL;
+        }
         ld->ld_error = LDAP_STRDUP( sasl_errdetail( ctx ) );
         rc = ld->ld_errno = sasl_err2ldap( saslrc, ld->saslint_errno );
         goto done;