Fix SEGV from improperly formed SUBSTRING/PRESENCE filter
[mat/samba.git] / lib / ldb / ldb_map / ldb_map_outbound.c
index c6c86e326a8a24c20eea4e84b6afb4117eb5586f..5be5e765158ccae2122b05bcf38996c602b91a08 100644 (file)
@@ -848,7 +848,7 @@ int map_subtree_collect_remote_simple(struct ldb_module *module, void *mem_ctx,
                int i;
                /* Map value */
                (*new)->u.substring.chunks = NULL;
-               for (i=0; tree->u.substring.chunks[i]; i++) {
+               for (i=0; tree->u.substring.chunks && tree->u.substring.chunks[i]; i++) {
                        (*new)->u.substring.chunks = talloc_realloc(*new, (*new)->u.substring.chunks, struct ldb_val *, i+2);
                        if (!(*new)->u.substring.chunks) {
                                talloc_free(*new);