r11111: fixed a talloc error in the dn shortcut code
authorAndrew Tridgell <tridge@samba.org>
Mon, 17 Oct 2005 11:27:29 +0000 (11:27 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:44:51 +0000 (13:44 -0500)
(This used to be commit e28a334eeb8fa22f686d0c1dc48b2977d85b9e10)

source4/lib/ldb/ldb_tdb/ldb_index.c

index e80cf74c6264af27b36e83aeb0ce39a6b31e8563..275aadbd78e235081de4e38ebe1d88a328884d21 100644 (file)
@@ -323,9 +323,17 @@ static int ltdb_index_dn_leaf(struct ldb_module *module,
        }
        if (ldb_attr_cmp(tree->u.equality.attr, "distinguishedName") == 0 ||
            ldb_attr_cmp(tree->u.equality.attr, "dn") == 0) {
-               char *dn = talloc_strdup(list, (char *)tree->u.equality.value.data);
+               list->dn = talloc_array(list, char *, 1);
+               if (list->dn == NULL) {
+                       ldb_oom(module->ldb);
+                       return -1;
+               }
+               list->dn[0] = talloc_strdup(list, (char *)tree->u.equality.value.data);
+               if (list->dn[0] == NULL) {
+                       ldb_oom(module->ldb);
+                       return -1;
+               }
                list->count = 1;
-               list->dn = &dn;
                return 1;
        }
        return ltdb_index_dn_simple(module, tree, index_list, list);
@@ -698,12 +706,17 @@ int ltdb_search_indexed(struct ldb_module *module,
 
        if (scope == LDB_SCOPE_BASE) {
                /* with BASE searches only one DN can match */
-               char *dn = ldb_dn_linearize(dn_list, base);
-               if (dn == NULL) {
+               dn_list->dn = talloc_array(dn_list, char *, 1);
+               if (dn_list->dn == NULL) {
+                       ldb_oom(module->ldb);
+                       return -1;
+               }
+               dn_list->dn[0] = ldb_dn_linearize(dn_list, base);
+               if (dn_list->dn[0] == NULL) {
+                       ldb_oom(module->ldb);
                        return -1;
                }
                dn_list->count = 1;
-               dn_list->dn = &dn;
                ret = 1;
        } else {
                ret = ltdb_index_dn(module, tree, ltdb->cache->indexlist, dn_list);