r509: fixed a memory handling bug that affects ldb with memory pools that
authorAndrew Tridgell <tridge@samba.org>
Thu, 6 May 2004 07:30:51 +0000 (07:30 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:51:46 +0000 (12:51 -0500)
change with each request
(This used to be commit 18695cefa16b867427e3ca2fb0d787d850ea25c3)

source4/lib/ldb/ldb_tdb/ldb_cache.c

index 6734de9fd896f2ce8b1cc2a24702fe640d13864e..87e9538d01b93f7a0b254a8b0a2586edbb66de16 100644 (file)
@@ -226,6 +226,7 @@ int ltdb_attribute_flags(struct ldb_context *ldb, const char *attr_name)
        };
        size_t len;
        int i, ret=0;
+       struct ldb_alloc_ops alloc = ldb->alloc_ops;
 
        if (ltdb->cache.last_attribute.name &&
            ldb_attr_cmp(ltdb->cache.last_attribute.name, attr_name) == 0) {
@@ -257,10 +258,14 @@ int ltdb_attribute_flags(struct ldb_context *ldb, const char *attr_name)
                attrs += strspn(attrs, " ,");
        }
 
-       if (ltdb->cache.last_attribute.name) ldb_free(ldb, ltdb->cache.last_attribute.name);
+       ldb->alloc_ops.alloc = NULL;
+
+       ldb_free(ldb, ltdb->cache.last_attribute.name);
 
        ltdb->cache.last_attribute.name = ldb_strdup(ldb, attr_name);
        ltdb->cache.last_attribute.flags = ret;
+
+       ldb->alloc_ops = alloc;
        
        return ret;
 }