[SCM] SAMBA-CTDB repository - branch v3-2-ctdb updated - build_3.2.7_ctdb.54-196-ge627e49

Michael Adam obnox at samba.org
Wed Mar 4 10:20:56 GMT 2009


The branch, v3-2-ctdb has been updated
       via  e627e495f56f3d3b9fcbab87d9c5899176c5ff65 (commit)
      from  ace9b51a1bee3500f83a531d14ccfdea2e3f4474 (commit)

http://gitweb.samba.org/?p=obnox/samba-ctdb.git;a=shortlog;h=v3-2-ctdb


- Log -----------------------------------------------------------------
commit e627e495f56f3d3b9fcbab87d9c5899176c5ff65
Author: Michael Adam <obnox at samba.org>
Date:   Fri Feb 27 15:28:52 2009 +0100

    s3: Fix a memleak in dbwrap_rbt.
    
    The SMB_MALLOC'ed rbt node data was not free'd on talloc free of
    the db context. This is a quick fix using talloc instead of malloc
    for allocation of the node data.
    
    Since malloc was originally used for performance reasons, one
    might want to reverse to malloc and create a talloc destructor
    that walks the tree and frees all the node data if this talloc
    approach proves to be too slow..
    
    Michael

-----------------------------------------------------------------------

Summary of changes:
 source/lib/dbwrap_rbt.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/lib/dbwrap_rbt.c b/source/lib/dbwrap_rbt.c
index b70ce3d..7747be7 100644
--- a/source/lib/dbwrap_rbt.c
+++ b/source/lib/dbwrap_rbt.c
@@ -131,12 +131,12 @@ static NTSTATUS db_rbt_store(struct db_record *rec, TDB_DATA data, int flag)
 		 */
 	}
 
-	node = (struct db_rbt_node *)SMB_MALLOC(
+	node = (struct db_rbt_node *)talloc_size(rec_priv->db_ctx,
 		offsetof(struct db_rbt_node, data) + rec->key.dsize
 		+ data.dsize);
 
 	if (node == NULL) {
-		SAFE_FREE(rec_priv->node);
+		TALLOC_FREE(rec_priv->node);
 		return NT_STATUS_NO_MEMORY;
 	}
 
@@ -148,7 +148,7 @@ static NTSTATUS db_rbt_store(struct db_record *rec, TDB_DATA data, int flag)
 	db_rbt_parse_node(node, &this_key, &this_val);
 
 	memcpy(this_key.dptr, rec->key.dptr, node->keysize);
-	SAFE_FREE(rec_priv->node);
+	TALLOC_FREE(rec_priv->node);
 
 	memcpy(this_val.dptr, data.dptr, node->valuesize);
 
@@ -194,7 +194,7 @@ static NTSTATUS db_rbt_delete(struct db_record *rec)
 	}
 
 	rb_erase(&rec_priv->node->rb_node, &rec_priv->db_ctx->tree);
-	SAFE_FREE(rec_priv->node);
+	TALLOC_FREE(rec_priv->node);
 
 	return NT_STATUS_OK;
 }


-- 
SAMBA-CTDB repository


More information about the samba-cvs mailing list