From 8c4711e9db9a0585b354bc17a7514282695758d1 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Fri, 31 Mar 2006 20:36:53 +0000 Subject: [PATCH] plug leaks --- libraries/libldap/cyrus.c | 8 ++++++-- libraries/libldap/schema.c | 10 +++++++--- libraries/libldap/test.c | 4 ++++ libraries/libldap/url.c | 12 ++++++++++-- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/libraries/libldap/cyrus.c b/libraries/libldap/cyrus.c index 873387317a..296e633731 100644 --- a/libraries/libldap/cyrus.c +++ b/libraries/libldap/cyrus.c @@ -1024,7 +1024,7 @@ int ldap_pvt_sasl_secprops( sasl_security_properties_t *secprops ) { int i, j, l; - char **props = ldap_str2charray( in, "," ); + char **props; unsigned sflags = 0; int got_sflags = 0; sasl_ssf_t max_ssf = 0; @@ -1034,7 +1034,11 @@ int ldap_pvt_sasl_secprops( unsigned maxbufsize = 0; int got_maxbufsize = 0; - if( props == NULL || secprops == NULL ) { + if( secprops == NULL ) { + return LDAP_PARAM_ERROR; + } + props = ldap_str2charray( in, "," ); + if( props == NULL ) { return LDAP_PARAM_ERROR; } diff --git a/libraries/libldap/schema.c b/libraries/libldap/schema.c index 820ae3a875..9e04633b00 100644 --- a/libraries/libldap/schema.c +++ b/libraries/libldap/schema.c @@ -1414,16 +1414,20 @@ add_extension(LDAPSchemaExtensionItem ***extensions, if ( !*extensions ) { *extensions = LDAP_CALLOC(2, sizeof(LDAPSchemaExtensionItem *)); - if ( !*extensions ) - return 1; + if ( !*extensions ) { + LDAP_FREE( ext ); + return 1; + } n = 0; } else { for ( n=0; (*extensions)[n] != NULL; n++ ) ; tmp = LDAP_REALLOC(*extensions, (n+2)*sizeof(LDAPSchemaExtensionItem *)); - if ( !tmp ) + if ( !tmp ) { + LDAP_FREE( ext ); return 1; + } *extensions = tmp; } (*extensions)[n] = ext; diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c index 1affb1c714..8806089312 100644 --- a/libraries/libldap/test.c +++ b/libraries/libldap/test.c @@ -205,6 +205,10 @@ get_modlist( 6 ) == 0 ) { if ( file_read( tmp.mod_values[i] + 6, bvals[i] ) < 0 ) { + free( bvals ); + for ( i = 0; ilud_host; ludp->lud_host = p; p = strchr( ludp->lud_host, ']' ); - if ( p == NULL ) + if ( p == NULL ) { + LDAP_FREE(ludp); + ldap_charray_free(specs); return LDAP_PARAM_ERROR; + } *p++ = '\0'; if ( *p != ':' ) { - if ( *p != '\0' ) + if ( *p != '\0' ) { + LDAP_FREE(ludp); + ldap_charray_free(specs); return LDAP_PARAM_ERROR; + } p = NULL; } } else { @@ -1328,6 +1334,8 @@ ldap_url_parsehosts( ldap_pvt_hex_unescape(p); ludp->lud_port = strtol( p, &next, 10 ); if ( next == p || next[0] != '\0' ) { + LDAP_FREE(ludp); + ldap_charray_free(specs); return LDAP_PARAM_ERROR; } } -- 2.39.5