]> git.sur5r.net Git - openldap/commitdiff
plug leaks
authorHoward Chu <hyc@openldap.org>
Tue, 4 Apr 2006 10:27:28 +0000 (10:27 +0000)
committerHoward Chu <hyc@openldap.org>
Tue, 4 Apr 2006 10:27:28 +0000 (10:27 +0000)
servers/slapd/back-ldbm/attr.c
servers/slapd/back-ldbm/idl.c

index 51bcb2f2871b92b573415ebfdd3fade8d6b718df..fddbff0b2d61cf525643e9acae8f3e9106859db2 100644 (file)
@@ -72,7 +72,7 @@ attr_index_config(
     int                        argc,
     char               **argv )
 {
-       int rc;
+       int rc = LDAP_SUCCESS;
        int     i;
        slap_mask_t mask;
        char **attrs;
@@ -94,7 +94,8 @@ attr_index_config(
                        fprintf( stderr, "%s: line %d: "
                                "no indexes specified: %s\n",
                                fname, lineno, argv[1] );
-                       return LDAP_PARAM_ERROR;
+                       rc = LDAP_PARAM_ERROR;
+                       goto fail;
                }
        }
 
@@ -112,7 +113,8 @@ attr_index_config(
                                fprintf( stderr, "%s: line %d: "
                                        "index type \"%s\" undefined\n",
                                        fname, lineno, indexes[i] );
-                               return LDAP_PARAM_ERROR;
+                               rc = LDAP_PARAM_ERROR;
+                               goto fail;
                        }
 
                        mask |= index;
@@ -123,7 +125,8 @@ attr_index_config(
                fprintf( stderr, "%s: line %d: "
                        "no indexes selected\n",
                        fname, lineno );
-               return LDAP_PARAM_ERROR;
+               rc = LDAP_PARAM_ERROR;
+               goto fail;
        }
 
        for ( i = 0; attrs[i] != NULL; i++ ) {
@@ -136,8 +139,6 @@ attr_index_config(
                        continue;
                }
 
-               a = (AttrInfo *) ch_malloc( sizeof(AttrInfo) );
-
                ad = NULL;
                rc = slap_str2ad( attrs[i], &ad, &text );
 
@@ -145,14 +146,15 @@ attr_index_config(
                        fprintf( stderr, "%s: line %d: "
                                "index attribute \"%s\" undefined\n",
                                fname, lineno, attrs[i] );
-                       return rc;
+                       goto fail;
                }
 
                if( slap_ad_is_binary( ad ) ) {
                        fprintf( stderr, "%s: line %d: "
                                "index of attribute \"%s\" disallowed\n",
                                fname, lineno, attrs[i] );
-                       return LDAP_UNWILLING_TO_PERFORM;
+                       rc = LDAP_UNWILLING_TO_PERFORM;
+                       goto fail;
                }
 
                if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) && !(
@@ -163,7 +165,8 @@ attr_index_config(
                        fprintf( stderr, "%s: line %d: "
                                "approx index of attribute \"%s\" disallowed\n",
                                fname, lineno, attrs[i] );
-                       return LDAP_INAPPROPRIATE_MATCHING;
+                       rc = LDAP_INAPPROPRIATE_MATCHING;
+                       goto fail;
                }
 
                if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) && !(
@@ -174,7 +177,8 @@ attr_index_config(
                        fprintf( stderr, "%s: line %d: "
                                "equality index of attribute \"%s\" disallowed\n",
                                fname, lineno, attrs[i] );
-                       return LDAP_INAPPROPRIATE_MATCHING;
+                       rc = LDAP_INAPPROPRIATE_MATCHING;
+                       goto fail;
                }
 
                if( IS_SLAP_INDEX( mask, SLAP_INDEX_SUBSTR ) && !(
@@ -185,12 +189,15 @@ attr_index_config(
                        fprintf( stderr, "%s: line %d: "
                                "substr index of attribute \"%s\" disallowed\n",
                                fname, lineno, attrs[i] );
-                       return LDAP_INAPPROPRIATE_MATCHING;
+
+                       rc = LDAP_INAPPROPRIATE_MATCHING;
+                       goto fail;
                }
 
                Debug( LDAP_DEBUG_CONFIG, "index %s 0x%04lx\n",
                        ad->ad_cname.bv_val, mask, 0 ); 
 
+               a = (AttrInfo *) ch_malloc( sizeof(AttrInfo) );
 
                a->ai_desc = ad;
 
@@ -203,15 +210,18 @@ attr_index_config(
                        fprintf( stderr,
                                "%s: line %d: duplicate index definition for attr \"%s\".\n",
                            fname, lineno, attrs[i] );
-
-                       return LDAP_PARAM_ERROR;
+                       ch_free( a );
+                       goto fail;
                }
        }
 
-       ldap_charray_free( attrs );
+       rc = LDAP_SUCCESS;
+
+fail:
        if ( indexes != NULL ) ldap_charray_free( indexes );
+       ldap_charray_free( attrs );
 
-       return LDAP_SUCCESS;
+       return rc;
 }
 
 void
index 6feeee00501382d5b9179011413a33dd03cf3e2f..dec8ef4c9e64036c8a2f232256d0f7bd80fc5b96 100644 (file)
@@ -112,6 +112,7 @@ idl_allids( Backend *be )
        idl = idl_alloc( 0 );
        ID_BLOCK_NMAX(idl) = ID_BLOCK_ALLIDS_VALUE;
        if ( next_id_get( be, &id ) ) {
+               idl_free( idl );
                return NULL;
        }
        ID_BLOCK_NIDS(idl) = id;