ldb: Cope with substring match with no chunks in ldb_filter_from_tree
authorAndrew Bartlett <abartlet@samba.org>
Sat, 22 Jun 2013 07:01:02 +0000 (17:01 +1000)
committerJeremy Allison <jra@samba.org>
Mon, 24 Jun 2013 19:54:18 +0000 (12:54 -0700)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
lib/ldb/common/ldb_parse.c

index 33e8444be7d3e11a7cee7f560efbf71bfe83dbfe..5fa5a74afa9d5721d207ab63ebc200347dd27b04 100644 (file)
@@ -748,7 +748,7 @@ char *ldb_filter_from_tree(TALLOC_CTX *mem_ctx, const struct ldb_parse_tree *tre
                ret = talloc_asprintf(mem_ctx, "(%s=%s", tree->u.substring.attr,
                                      tree->u.substring.start_with_wildcard?"*":"");
                if (ret == NULL) return NULL;
-               for (i = 0; tree->u.substring.chunks[i]; i++) {
+               for (i = 0; tree->u.substring.chunks && tree->u.substring.chunks[i]; i++) {
                        s2 = ldb_binary_encode(mem_ctx, *(tree->u.substring.chunks[i]));
                        if (s2 == NULL) {
                                talloc_free(ret);