]> git.sur5r.net Git - openldap/commitdiff
Fix entry_alloc with no attrs
authorHoward Chu <hyc@openldap.org>
Wed, 14 Sep 2011 17:14:02 +0000 (10:14 -0700)
committerHoward Chu <hyc@openldap.org>
Wed, 14 Sep 2011 17:14:02 +0000 (10:14 -0700)
servers/slapd/back-mdb/id2entry.c

index 757f21041b4ffb01fccdd65ac65ab30bf74ce7d9..2d0e00e4a05f35748c485987fdcebd1023ef9e7a 100644 (file)
@@ -177,8 +177,12 @@ static Entry * mdb_entry_alloc(
                nvals * sizeof(struct berval), op->o_tmpmemctx );
        BER_BVZERO(&e->e_bv);
        e->e_private = e;
-       e->e_attrs = (Attribute *)(e+1);
-       e->e_attrs->a_vals = (struct berval *)(e->e_attrs+nattrs);
+       if (nattrs) {
+               e->e_attrs = (Attribute *)(e+1);
+               e->e_attrs->a_vals = (struct berval *)(e->e_attrs+nattrs);
+       } else {
+               e->e_attrs = NULL;
+       }
 
        return e;
 }