]> git.sur5r.net Git - openldap/commitdiff
plug leaks
authorHoward Chu <hyc@openldap.org>
Fri, 31 Mar 2006 12:20:04 +0000 (12:20 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 31 Mar 2006 12:20:04 +0000 (12:20 +0000)
servers/slapd/back-bdb/idl.c
servers/slapd/back-monitor/init.c
servers/slapd/bconfig.c
servers/slapd/config.c
servers/slapd/cr.c
servers/slapd/mr.c
servers/slapd/oidm.c
servers/slapd/schema_prep.c
servers/slapd/slaptest.c

index 84629c10cf6e777a09059c966b5b96f990b1ecab..97cf1bd8e2c30d8a7b64aef2008137c22e41a653 100644 (file)
@@ -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 );
                }
        }
index 249b3641635e7d9d35678127802bf17aa59e07d0..264b70c5c7ebeaddb433fa30b15d6b6d955bb8c4 100644 (file)
@@ -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 );
index 49a2ce73704221176acb96ab0f621f4215bcb07e..69c2da66644df2aef4c935615523139830a13c6f 100644 (file)
@@ -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;
 }
index 8aa711d7041cfcad582b7620c45e9f88dd0b6715..8e8558c053b72ea06e576859d2f3cc1757409e48 100644 (file)
@@ -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;
 }
index 366246e1231b2c7d0787e455a1fc5c9e75d95ece..19c0bfa7cd4b8c1d1af6ba1a5dd4b0a0245519b6 100644 (file)
@@ -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
index 32165263fb475015a3e94d21cbc5030e6ce99524..4ca235e7e518df32e7d2c04bd84f01f37eba7c2f 100644 (file)
@@ -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);
index 0bc6f53102d32896b7c1c0101d8d258b1fa0a7aa..24ed7d1b217d0acf3ec978afd3eaf2e82b100497 100644 (file)
@@ -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 <name> <oid>\n");
+               if (om) SLAP_FREE( om );
                return 1;
        }
 
@@ -116,6 +117,7 @@ usage:      fprintf( stderr, "\tObjectIdentifier <name> <oid>\n");
                        "%s: line %d: "
                        "ObjectIdentifier \"%s\" previously defined \"%s\"",
                        fname, lineno, argv[1], oid );
+               SLAP_FREE( oid );
                return 1;
        }
 
index 001af17ef56465c159494423338e0f94a4d459a0..92d7feae6b701821c16c4a85745d6d5a43219b81 100644 (file)
@@ -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 **)
index e0de63628a57fcd040247a3215a5d2e45b04d4f7..a1c6baba0f7b43ce7dac97ab215916ead8536f96 100644 (file)
@@ -69,6 +69,7 @@ test_file( const char *fname, const char *ftype )
 
                                return -1;
                        }
+                       fclose( fp );
                        unlink( fname );
                        break;
                }