]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/ad.c
fix previous commit (ITS#5819)
[openldap] / servers / slapd / ad.c
index 4dcce9372e0ec8b10ddb79c7c3e2ce6cf242e408..b43df86ca6dd77341e7b643b7a1511e3449370a5 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1998-2007 The OpenLDAP Foundation.
+ * Copyright 1998-2008 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -817,7 +817,10 @@ undef_promote(
 
                        *u_ad = (*u_ad)->ad_next;
 
+                       tmp->ad_type = nat;
                        tmp->ad_next = NULL;
+                       /* ad_cname was contiguous, no leak here */
+                       tmp->ad_cname = nat->sat_cname;
                        *n_ad = tmp;
                        n_ad = &tmp->ad_next;
                } else {
@@ -963,10 +966,8 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
        return( an );
 
 reterr:
-       for ( i = 0; an[i].an_name.bv_val; i++ ) {
-               free( an[i].an_name.bv_val );
-       }
-       free( an );
+       anlist_free( an, 1, NULL );
+
        /*
         * overwrites input string
         * on error!
@@ -976,6 +977,24 @@ reterr:
        return NULL;
 }
 
+void
+anlist_free( AttributeName *an, int freename, void *ctx )
+{
+       if ( an == NULL ) {
+               return;
+       }
+
+       if ( freename ) {
+               int     i;
+
+               for ( i = 0; an[i].an_name.bv_val; i++ ) {
+                       ber_memfree_x( an[i].an_name.bv_val, ctx );
+               }
+       }
+
+       ber_memfree_x( an, ctx );
+}
+
 char **anlist2charray_x( AttributeName *an, int dup, void *ctx )
 {
     char **attrs;