ldb_tdb: Clean up list in after use in ltdb_key_dn_from_idx()
authorAndrew Bartlett <abartlet@samba.org>
Fri, 1 Sep 2017 10:25:43 +0000 (22:25 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 22 Sep 2017 19:20:24 +0000 (21:20 +0200)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb/ldb_tdb/ldb_index.c

index 1fc0a082757d0c011180a1d694e62b0588ee4033..25439c3d9d406e816d3e214046ffc8bf6b32c1eb 100644 (file)
@@ -347,10 +347,12 @@ int ltdb_key_dn_from_idx(struct ldb_module *module,
 
        ret = ltdb_index_dn_base_dn(module, ltdb, dn, list);
        if (ret != LDB_SUCCESS) {
+               TALLOC_FREE(list);
                return ret;
        }
 
        if (list->count == 0) {
+               TALLOC_FREE(list);
                return LDB_ERR_NO_SUCH_OBJECT;
        }
        if (list->count > 1) {
@@ -369,6 +371,7 @@ int ltdb_key_dn_from_idx(struct ldb_module *module,
        /* The tdb_key memory is allocated by the caller */
        ret = ltdb_guid_to_key(module, ltdb,
                               &list->dn[0], tdb_key);
+       TALLOC_FREE(list);
 
        if (ret != LDB_SUCCESS) {
                return LDB_ERR_OPERATIONS_ERROR;