summaryrefslogtreecommitdiff
path: root/lib/dbwrap
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2012-05-30 16:50:06 +0200
committerStefan Metzmacher <metze@samba.org>2012-05-31 00:53:19 +0200
commit39ac9457a3d75a344b6ca41a7df3122eb9c5b26e (patch)
tree2b1b7245ef85257d50555e547d394d68a4a0e06d /lib/dbwrap
parenta06b9b413e6e739310d6f0e95ad5d31f9503482a (diff)
downloadsamba-39ac9457a3d75a344b6ca41a7df3122eb9c5b26e.tar.gz
samba-39ac9457a3d75a344b6ca41a7df3122eb9c5b26e.tar.bz2
samba-39ac9457a3d75a344b6ca41a7df3122eb9c5b26e.zip
lib/dbwrap: don't alter the record on failure in db_rbt_store()
metze
Diffstat (limited to 'lib/dbwrap')
-rw-r--r--lib/dbwrap/dbwrap_rbt.c19
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;