ldb:ldb_cache.c - fix memory contexts and memory leaks
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Wed, 20 Oct 2010 12:08:53 +0000 (14:08 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Wed, 20 Oct 2010 12:31:05 +0000 (12:31 +0000)
source4/lib/ldb/ldb_tdb/ldb_cache.c

index 114eadaff52dff4cf83554ddd2473a2ddf108a0a..6b1eb5b148cdbd45968aaba6fbd80a114a551b72 100644 (file)
@@ -298,7 +298,7 @@ int ltdb_cache_load(struct ldb_module *module)
        baseinfo = ldb_msg_new(ltdb->cache);
        if (baseinfo == NULL) goto failed;
 
-       baseinfo_dn = ldb_dn_new(module, ldb, LTDB_BASEINFO);
+       baseinfo_dn = ldb_dn_new(baseinfo, ldb, LTDB_BASEINFO);
        if (baseinfo_dn == NULL) goto failed;
 
        r= ltdb_search_dn1(module, baseinfo_dn, baseinfo);
@@ -351,6 +351,7 @@ int ltdb_cache_load(struct ldb_module *module)
        ltdb_attributes_unload(module);
 
        talloc_free(ltdb->cache->indexlist);
+       talloc_free(ltdb->cache->attributes);
 
        ltdb->cache->indexlist = ldb_msg_new(ltdb->cache);
        ltdb->cache->attributes = ldb_msg_new(ltdb->cache);
@@ -383,14 +384,12 @@ int ltdb_cache_load(struct ldb_module *module)
 done:
        talloc_free(options);
        talloc_free(baseinfo);
-       talloc_free(baseinfo_dn);
        talloc_free(indexlist_dn);
        return 0;
 
 failed:
        talloc_free(options);
        talloc_free(baseinfo);
-       talloc_free(baseinfo_dn);
        talloc_free(indexlist_dn);
        return -1;
 }
@@ -422,6 +421,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module)
 
        s = talloc_asprintf(msg, "%llu", ltdb->sequence_number+1);
        if (!s) {
+               talloc_free(msg);
                errno = ENOMEM;
                return LDB_ERR_OPERATIONS_ERROR;
        }
@@ -458,6 +458,7 @@ int ltdb_increase_sequence_number(struct ldb_module *module)
 
        s = ldb_timestring(msg, t);
        if (s == NULL) {
+               talloc_free(msg);
                return LDB_ERR_OPERATIONS_ERROR;
        }