ldb_tdb: Reduce memory consumption in list_intersect()
authorAndrew Bartlett <abartlet@samba.org>
Mon, 21 Aug 2017 23:17:56 +0000 (11:17 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Sep 2017 19:20:23 +0000 (21:20 +0200)
We will never have more results than is in either list or list2.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb/ldb_tdb/ldb_index.c

index 16897209b03a157cbd79a12d6d199bfa0ac8c06c..49153475b5e9316e0894f17d6b5d4d70fbb210a4 100644 (file)
@@ -885,7 +885,8 @@ static bool list_intersect(struct ldb_context *ldb,
                return false;
        }
 
-       list3->dn = talloc_array(list3, struct ldb_val, list->count);
+       list3->dn = talloc_array(list3, struct ldb_val,
+                                MIN(list->count, list2->count));
        if (!list3->dn) {
                talloc_free(list3);
                return false;