]> git.sur5r.net Git - openldap/commitdiff
fix ITS#2330; free rdn after usage
authorPierangelo Masarati <ando@openldap.org>
Wed, 26 Feb 2003 21:47:47 +0000 (21:47 +0000)
committerPierangelo Masarati <ando@openldap.org>
Wed, 26 Feb 2003 21:47:47 +0000 (21:47 +0000)
servers/slapd/schema_check.c

index d2fb876ba7f7ac911fd1b81d386ed14300f2f057..60f866f6658937985a84db55d093dc48b1593da1 100644 (file)
@@ -219,9 +219,9 @@ entry_schema_check(
        }
 
        {       /* naming check */
-               LDAPRDN *rdn;
-               const char *p;
-               ber_len_t cnt;
+               LDAPRDN         *rdn = NULL;
+               const char      *p = NULL;
+               ber_len_t       cnt;
 
                /*
                 * Get attribute type(s) and attribute value(s) of our RDN
@@ -230,7 +230,8 @@ entry_schema_check(
                        LDAP_DN_FORMAT_LDAP ) )
                {
                        *text = "unrecongized attribute type(s) in RDN";
-                       return LDAP_INVALID_DN_SYNTAX;
+                       rc = LDAP_INVALID_DN_SYNTAX;
+                       goto rdn_check_done;
                }
 
                /* Check that each AVA of the RDN is present in the entry */
@@ -244,7 +245,7 @@ entry_schema_check(
                        rc = slap_bv2ad( &ava->la_attr, &desc, &errtext );
                        if ( rc != LDAP_SUCCESS ) {
                                snprintf( textbuf, textlen, "%s (in RDN)", errtext );
-                               return rc;
+                               goto rdn_check_done;
                        }
 
                        /* find the naming attribute */
@@ -252,17 +253,25 @@ entry_schema_check(
                        if ( attr == NULL ) {
                                snprintf( textbuf, textlen, 
                                        "naming attribute '%s' is not present in entry",
-                                       ava->la_attr );
-                               return LDAP_NO_SUCH_ATTRIBUTE;
+                                       ava->la_attr.bv_val );
+                               rc = LDAP_NO_SUCH_ATTRIBUTE;
+                               goto rdn_check_done;
                        }
 
                        if ( value_find( desc, attr->a_vals, &ava->la_value ) != 0 ) {
                                snprintf( textbuf, textlen, 
                                        "value of naming attribute '%s' is not present in entry",
-                                       ava->la_attr );
-                               return LDAP_NO_SUCH_ATTRIBUTE;
+                                       ava->la_attr.bv_val );
+                               rc = LDAP_NO_SUCH_ATTRIBUTE;
+                               goto rdn_check_done;
                        }
                }
+
+rdn_check_done:;
+               ldap_rdnfree( rdn );
+               if ( rc != LDAP_SUCCESS ) {
+                       return rc;
+               }
        }
 
 #ifdef SLAP_EXTENDED_SCHEMA