diff options
Diffstat (limited to 'lib/dbwrap')
-rw-r--r-- | lib/dbwrap/dbwrap_rbt.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/dbwrap/dbwrap_rbt.c b/lib/dbwrap/dbwrap_rbt.c index a87b85fe27..2cc52b1da6 100644 --- a/lib/dbwrap/dbwrap_rbt.c +++ b/lib/dbwrap/dbwrap_rbt.c @@ -121,7 +121,17 @@ static NTSTATUS db_rbt_store(struct db_record *rec, TDB_DATA data, int flag) rec_priv->node->valuesize = data.dsize; return NT_STATUS_OK; } + } + + node = (struct db_rbt_node *)talloc_size(db_ctx, + offsetof(struct db_rbt_node, data) + rec->key.dsize + + data.dsize); + + if (node == NULL) { + return NT_STATUS_NO_MEMORY; + } + if (rec_priv->node != NULL) { /* * We need to delete the key from the tree and start fresh, * there's not enough space in the existing record @@ -135,15 +145,6 @@ static NTSTATUS db_rbt_store(struct db_record *rec, TDB_DATA data, int flag) */ } - node = (struct db_rbt_node *)talloc_size(db_ctx, - offsetof(struct db_rbt_node, data) + rec->key.dsize - + data.dsize); - - if (node == NULL) { - TALLOC_FREE(rec_priv->node); - return NT_STATUS_NO_MEMORY; - } - ZERO_STRUCT(node->rb_node); node->keysize = rec->key.dsize; |