Move the check above the talloc
authorAnatoliy Atanasov <anatoliy.atanasov@postpath.com>
Tue, 22 Sep 2009 21:37:58 +0000 (14:37 -0700)
committerAnatoliy Atanasov <anatoliy.atanasov@postpath.com>
Tue, 22 Sep 2009 21:46:18 +0000 (14:46 -0700)
source4/lib/ldb/common/ldb_dn.c

index af00ef96f3035c5a4485e6abdcf6ff158fcafe98..12a513fc429992fb2e6aa4ce3d5be354d5919406 100644 (file)
@@ -88,6 +88,12 @@ struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx,
 
        if (! ldb) return NULL;
 
+       if (strdn && strdn->data
+           && (strlen((const char*)strdn->data) != strdn->length)) {
+               /* The RDN must not contain a character with value 0x0 */
+               return NULL;
+       }
+
        dn = talloc_zero(mem_ctx, struct ldb_dn);
        LDB_DN_NULL_FAILED(dn);
 
@@ -103,11 +109,6 @@ struct ldb_dn *ldb_dn_from_ldb_val(void *mem_ctx,
                dn->ext_linearized = talloc_strndup(dn, data, length);
                LDB_DN_NULL_FAILED(dn->ext_linearized);
 
-               if (strlen(data) != length) {
-                       /* The RDN must not contain a character with value 0x0 */
-                       return NULL;
-               }
-
                if (data[0] == '<') {
                        const char *p_save, *p = dn->ext_linearized;
                        do {