]> git.sur5r.net Git - openldap/commitdiff
plug leaks
authorHoward Chu <hyc@openldap.org>
Fri, 31 Mar 2006 11:15:26 +0000 (11:15 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 31 Mar 2006 11:15:26 +0000 (11:15 +0000)
servers/slapd/back-bdb/attr.c
servers/slapd/component.c
servers/slapd/config.c
servers/slapd/daemon.c
servers/slapd/dn.c

index a98dbb7558f28d1e62478450762f0f78fc691a5f..15a28a91ba2bf6b9363365a168195811061c4a00 100644 (file)
@@ -94,7 +94,7 @@ bdb_attr_index_config(
        int                     argc,
        char            **argv )
 {
-       int rc;
+       int rc = 0;
        int     i;
        slap_mask_t mask;
        char **attrs;
@@ -116,7 +116,8 @@ bdb_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 done;
                }
        }
 
@@ -134,7 +135,8 @@ bdb_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 done;
                        }
 
                        mask |= index;
@@ -145,7 +147,8 @@ bdb_attr_index_config(
                fprintf( stderr, "%s: line %d: "
                        "no indexes selected\n",
                        fname, lineno );
-               return LDAP_PARAM_ERROR;
+               rc = LDAP_PARAM_ERROR;
+               goto done;
        }
 
        for ( i = 0; attrs[i] != NULL; i++ ) {
@@ -169,7 +172,7 @@ bdb_attr_index_config(
                                fprintf( stderr, "%s: line %d: "
                                        "index component reference\"%s\" undefined\n",
                                        fname, lineno, attrs[i] );
-                               return rc;
+                               goto done;
                        }
                        cr->cr_indexmask = mask;
                        /*
@@ -179,11 +182,6 @@ bdb_attr_index_config(
                } else {
                        cr = NULL;
                }
-#endif
-               a = (AttrInfo *) ch_malloc( sizeof(AttrInfo) );
-
-#ifdef LDAP_COMP_MATCH
-               a->ai_cr = NULL;
 #endif
                ad = NULL;
                rc = slap_str2ad( attrs[i], &ad, &text );
@@ -192,14 +190,15 @@ bdb_attr_index_config(
                        fprintf( stderr, "%s: line %d: "
                                "index attribute \"%s\" undefined\n",
                                fname, lineno, attrs[i] );
-                       return rc;
+                       goto done;
                }
 
                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 done;
                }
 
                if( IS_SLAP_INDEX( mask, SLAP_INDEX_APPROX ) && !(
@@ -210,7 +209,8 @@ bdb_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 done;
                }
 
                if( IS_SLAP_INDEX( mask, SLAP_INDEX_EQUALITY ) && !(
@@ -221,7 +221,8 @@ bdb_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 done;
                }
 
                if( IS_SLAP_INDEX( mask, SLAP_INDEX_SUBSTR ) && !(
@@ -232,12 +233,18 @@ bdb_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 done;
                }
 
                Debug( LDAP_DEBUG_CONFIG, "index %s 0x%04lx\n",
                        ad->ad_cname.bv_val, mask, 0 ); 
 
+               a = (AttrInfo *) ch_malloc( sizeof(AttrInfo) );
+
+#ifdef LDAP_COMP_MATCH
+               a->ai_cr = NULL;
+#endif
                a->ai_desc = ad;
 
                if ( bdb->bi_flags & BDB_IS_OPEN ) {
@@ -260,14 +267,16 @@ bdb_attr_index_config(
                                rc = insert_component_reference( cr, &a_cr->ai_cr );
                                if ( rc != LDAP_SUCCESS) {
                                        fprintf( stderr, " error during inserting component reference in %s ", attrs[i]);
-                                       return LDAP_PARAM_ERROR;
+                                       rc = LDAP_PARAM_ERROR;
+                                       goto done;
                                }
                                continue;
                        } else {
                                rc = insert_component_reference( cr, &a->ai_cr );
                                if ( rc != LDAP_SUCCESS) {
                                        fprintf( stderr, " error during inserting component reference in %s ", attrs[i]);
-                                       return LDAP_PARAM_ERROR;
+                                       rc = LDAP_PARAM_ERROR;
+                                       goto done;
                                }
                        }
                }
@@ -289,14 +298,16 @@ bdb_attr_index_config(
                                "%s: line %d: duplicate index definition for attr \"%s\".\n",
                                fname, lineno, attrs[i] );
 
-                       return LDAP_PARAM_ERROR;
+                       rc = LDAP_PARAM_ERROR;
+                       goto done;
                }
        }
 
+done:
        ldap_charray_free( attrs );
        if ( indexes != NULL ) ldap_charray_free( indexes );
 
-       return LDAP_SUCCESS;
+       return rc;
 }
 
 static int
index 0b6cb2d51979ee6006437ac1ce26f16706dc11f7..67693a61ac60419e8062e21e80aa9ea47f584736 100644 (file)
@@ -580,6 +580,11 @@ get_component_reference(
                        cr_list = &(*cr_list)->ci_next;
 
                } else if ( rc == LDAP_COMPREF_UNDEFINED ) {
+                       if ( op ) {
+                               op->o_tmpfree( ca_comp_ref , op->o_tmpmemctx );
+                       } else {
+                               free( ca_comp_ref );
+                       }
                        return rc;
                }
        }
index ca20e923808b0059e1f16a42c593672e9798f580..8aa711d7041cfcad582b7620c45e9f88dd0b6715 100644 (file)
@@ -692,6 +692,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
                Debug(LDAP_DEBUG_ANY,
                    "could not stat config file \"%s\": %s (%d)\n",
                    fname, strerror(errno), errno);
+               ch_free( c );
                return(1);
        }
 
@@ -700,6 +701,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
                Debug(LDAP_DEBUG_ANY,
                    "regular file expected, got \"%s\"\n",
                    fname, 0, 0 );
+               ch_free( c );
                return(1);
        }
 
@@ -709,6 +711,7 @@ read_config_file(const char *fname, int depth, ConfigArgs *cf, ConfigTable *cft)
                Debug(LDAP_DEBUG_ANY,
                    "could not open config file \"%s\": %s (%d)\n",
                    fname, strerror(errno), errno);
+               ch_free( c );
                return(1);
        }
 
index b1724ed3a140502547e7dcbdbf4582746a85e33b..004a3435c9e31e50e5282247c59ea5da0f66590f 100644 (file)
@@ -1157,6 +1157,8 @@ int slapd_daemon_init( const char *urls )
        if( u == NULL || u[0] == NULL ) {
                Debug( LDAP_DEBUG_ANY, "daemon_init: no urls (%s) provided.\n",
                        urls, 0, 0 );
+               if ( u )
+                       ldap_charray_free( u );
                return -1;
        }
 
index c6be5e99cb61d94df591ff3c238579cf4913893d..7effba1534808bad1945ca07ea6d61a21de3f780 100644 (file)
@@ -1319,7 +1319,7 @@ build_new_dn( struct berval * new_dn,
        char *ptr;
 
        if ( parent_dn == NULL || parent_dn->bv_len == 0 ) {
-               ber_dupbv( new_dn, newrdn );
+               ber_dupbv_x( new_dn, newrdn, memctx );
                return;
        }