From: Howard Chu Date: Fri, 31 Mar 2006 12:20:04 +0000 (+0000) Subject: plug leaks X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~85 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0af1940f3fb59fe57b2281ef253fe1341c505c2c;p=openldap plug leaks --- diff --git a/servers/slapd/back-bdb/idl.c b/servers/slapd/back-bdb/idl.c index 84629c10cf..97cf1bd8e2 100644 --- a/servers/slapd/back-bdb/idl.c +++ b/servers/slapd/back-bdb/idl.c @@ -473,8 +473,7 @@ bdb_idl_cache_del_id( IDL_LRU_DELETE( bdb, cache_entry ); ldap_pvt_thread_mutex_unlock( &bdb->bi_idl_tree_lrulock ); free( cache_entry->kstr.bv_val ); - if ( cache_entry->idl ) - free( cache_entry->idl ); + free( cache_entry->idl ); free( cache_entry ); } } diff --git a/servers/slapd/back-monitor/init.c b/servers/slapd/back-monitor/init.c index 249b364163..264b70c5c7 100644 --- a/servers/slapd/back-monitor/init.c +++ b/servers/slapd/back-monitor/init.c @@ -1285,6 +1285,7 @@ monitor_back_initialize( } if ( at->at_oid == NULL ) { + ldap_attributetype_free(at); Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: " "null OID for attributeType \"%s\"\n", mat[ i ].name, 0, 0 ); @@ -1293,6 +1294,7 @@ monitor_back_initialize( code = at_add(at, 0, NULL, &err); if ( code ) { + ldap_attributetype_free(at); Debug( LDAP_DEBUG_ANY, "monitor_back_db_init: " "%s in attributeType \"%s\"\n", scherr2str(code), mat[ i ].name, 0 ); @@ -1328,6 +1330,7 @@ monitor_back_initialize( } if ( oc->oc_oid == NULL ) { + ldap_objectclass_free(oc); Debug( LDAP_DEBUG_ANY, "objectclass \"%s\" has no OID\n" , moc[ i ].name, 0, 0 ); @@ -1336,12 +1339,12 @@ monitor_back_initialize( code = oc_add(oc, 0, NULL, &err); if ( code ) { + ldap_objectclass_free(oc); Debug( LDAP_DEBUG_ANY, "objectclass \"%s\": %s \"%s\"\n" , moc[ i ].name, scherr2str(code), err ); return -1; } - ldap_memfree(oc); Oc = oc_find( moc[ i ].name ); diff --git a/servers/slapd/bconfig.c b/servers/slapd/bconfig.c index 49a2ce7370..69c2da6664 100644 --- a/servers/slapd/bconfig.c +++ b/servers/slapd/bconfig.c @@ -4080,6 +4080,11 @@ out: } ch_free( ca->argv ); if ( colst ) ch_free( colst ); + while( dels ) { + deltail = dels->next; + ch_free( dels ); + dels = deltail; + } return rc; } diff --git a/servers/slapd/config.c b/servers/slapd/config.c index 8aa711d704..8e8558c053 100644 --- a/servers/slapd/config.c +++ b/servers/slapd/config.c @@ -488,7 +488,7 @@ init_config_attrs(ConfigTable *ct) { } } code = slap_str2ad( at->at_names[0], &ct[i].ad, &err ); - if ( freeit ) { + if ( freeit || code ) { ldap_attributetype_free( at ); } else { ldap_memfree( at ); @@ -523,10 +523,14 @@ init_config_ocs( ConfigOCs *ocs ) { if ( code && code != SLAP_SCHERR_CLASS_DUP ) { fprintf( stderr, "init_config_ocs: objectclass \"%s\": %s, %s\n", ocs[i].co_def, scherr2str(code), err ); + ldap_objectclass_free(oc); return code; } ocs[i].co_oc = oc_find(oc->oc_names[0]); - ldap_memfree(oc); + if ( code ) + ldap_objectclass_free(oc); + else + ldap_memfree(oc); } return 0; } diff --git a/servers/slapd/cr.c b/servers/slapd/cr.c index 366246e123..19c0bfa7cd 100644 --- a/servers/slapd/cr.c +++ b/servers/slapd/cr.c @@ -372,38 +372,44 @@ cr_add( scr->scr_sclass = oc_find(cr->cr_oid); if ( !scr->scr_sclass ) { *err = cr->cr_oid; - return SLAP_SCHERR_CLASS_NOT_FOUND; + code = SLAP_SCHERR_CLASS_NOT_FOUND; + goto fail; } /* check object class usage */ if( scr->scr_sclass->soc_kind != LDAP_SCHEMA_STRUCTURAL ) { *err = cr->cr_oid; - return SLAP_SCHERR_CR_BAD_STRUCT; + code = SLAP_SCHERR_CR_BAD_STRUCT; + goto fail; } if( scr->scr_sclass->soc_flags & SLAP_OC_OPERATIONAL ) op++; code = cr_add_auxiliaries( scr, &op, err ); - if ( code != 0 ) return code; + if ( code != 0 ) goto fail; code = cr_create_required( scr, &op, err ); - if ( code != 0 ) return code; + if ( code != 0 ) goto fail; code = cr_create_allowed( scr, &op, err ); - if ( code != 0 ) return code; + if ( code != 0 ) goto fail; code = cr_create_precluded( scr, &op, err ); - if ( code != 0 ) return code; + if ( code != 0 ) goto fail; if( user && op ) { - return SLAP_SCHERR_CR_BAD_AUX; + code = SLAP_SCHERR_CR_BAD_AUX; + goto fail; } code = cr_insert(scr,err); if ( code == 0 && rscr ) *rscr = scr; return code; +fail: + ch_free( scr ); + return code; } void diff --git a/servers/slapd/mr.c b/servers/slapd/mr.c index 32165263fb..4ca235e7e5 100644 --- a/servers/slapd/mr.c +++ b/servers/slapd/mr.c @@ -169,6 +169,7 @@ mr_add( for( i=0; def->mrd_compat_syntaxes[i]; i++ ) { compat_syn[i] = syn_find( def->mrd_compat_syntaxes[i] ); if( compat_syn[i] == NULL ) { + ch_free( compat_syn ); return SLAP_SCHERR_SYN_NOT_FOUND; } } @@ -198,10 +199,12 @@ mr_add( smr->smr_syntax = syn; } else { *err = smr->smr_syntax_oid; + ch_free( smr ); return SLAP_SCHERR_SYN_NOT_FOUND; } } else { *err = ""; + ch_free( smr ); return SLAP_SCHERR_MR_INCOMPLETE; } code = mr_insert(smr,err); diff --git a/servers/slapd/oidm.c b/servers/slapd/oidm.c index 0bc6f53102..24ed7d1b21 100644 --- a/servers/slapd/oidm.c +++ b/servers/slapd/oidm.c @@ -100,13 +100,14 @@ parse_oidm( OidMacro **rom) { char *oid; - OidMacro *om; + OidMacro *om = NULL; struct berval bv; if (argc != 3) { fprintf( stderr, "%s: line %d: too many arguments\n", fname, lineno ); usage: fprintf( stderr, "\tObjectIdentifier \n"); + if (om) SLAP_FREE( om ); return 1; } @@ -116,6 +117,7 @@ usage: fprintf( stderr, "\tObjectIdentifier \n"); "%s: line %d: " "ObjectIdentifier \"%s\" previously defined \"%s\"", fname, lineno, argv[1], oid ); + SLAP_FREE( oid ); return 1; } diff --git a/servers/slapd/schema_prep.c b/servers/slapd/schema_prep.c index 001af17ef5..92d7feae6b 100644 --- a/servers/slapd/schema_prep.c +++ b/servers/slapd/schema_prep.c @@ -1202,6 +1202,7 @@ slap_schema_load( void ) fprintf( stderr, "slap_schema_load: " "AttributeType \"%s\": no OID\n", ad_map[i].ssam_name ); + ldap_attributetype_free( at ); return LDAP_OTHER; } @@ -1317,18 +1318,20 @@ slap_schema_load( void ) fprintf( stderr, "slap_schema_load: ObjectClass " "\"%s\": no OID\n", oc_map[i].ssom_name ); + ldap_objectclass_free( oc ); return LDAP_OTHER; } code = oc_add(oc,0,NULL,&err); if ( code ) { + ldap_objectclass_free( oc ); fprintf( stderr, "slap_schema_load: ObjectClass " "\"%s\": %s: \"%s\"\n", oc_map[i].ssom_name, scherr2str(code), err); return code; } - ldap_memfree(oc); + } { ObjectClass ** ocp = (ObjectClass **) diff --git a/servers/slapd/slaptest.c b/servers/slapd/slaptest.c index e0de63628a..a1c6baba0f 100644 --- a/servers/slapd/slaptest.c +++ b/servers/slapd/slaptest.c @@ -69,6 +69,7 @@ test_file( const char *fname, const char *ftype ) return -1; } + fclose( fp ); unlink( fname ); break; }