]> git.sur5r.net Git - openldap/commitdiff
ITS#7143 fix attr_dup2 when no values are present (attrsOnly = TRUE)
authorHoward Chu <hyc@openldap.org>
Wed, 15 Feb 2012 01:29:14 +0000 (17:29 -0800)
committerHoward Chu <hyc@openldap.org>
Wed, 15 Feb 2012 01:29:14 +0000 (17:29 -0800)
servers/slapd/attr.c

index 9fec8955dd1957cf65658e48c832a584ee747265..f2f74effc135d0369849febdb50e5a4e443f6435 100644 (file)
@@ -232,13 +232,16 @@ attr_dup2( Attribute *tmp, Attribute *a )
                if ( a->a_nvals != a->a_vals ) {
 
                        tmp->a_nvals = ch_malloc( (tmp->a_numvals + 1) * sizeof(struct berval) );
-                       for ( j = 0; !BER_BVISNULL( &a->a_nvals[j] ); j++ ) {
-                               assert( j < i );
-                               ber_dupbv( &tmp->a_nvals[j], &a->a_nvals[j] );
-                               if ( BER_BVISNULL( &tmp->a_nvals[j] ) ) break;
-                               /* FIXME: error? */
+                       j = 0;
+                       if ( i ) {
+                               for ( ; !BER_BVISNULL( &a->a_nvals[j] ); j++ ) {
+                                       assert( j < i );
+                                       ber_dupbv( &tmp->a_nvals[j], &a->a_nvals[j] );
+                                       if ( BER_BVISNULL( &tmp->a_nvals[j] ) ) break;
+                                       /* FIXME: error? */
+                               }
+                               assert( j == i );
                        }
-                       assert( j == i );
                        BER_BVZERO( &tmp->a_nvals[j] );
 
                } else {