summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2008-08-07 18:34:54 +1000
committerMichael Adam <obnox@samba.org>2008-08-13 11:54:09 +0200
commitee314d6930881602962bfaeb81778b17314e1cf5 (patch)
treeac11f4d486973b66e7d27dab6df97324413560ff /source3
parent9bf211db6d7d6ef6e59508de69d6d8dfe5bae059 (diff)
downloadsamba-ee314d6930881602962bfaeb81778b17314e1cf5.tar.gz
samba-ee314d6930881602962bfaeb81778b17314e1cf5.tar.bz2
samba-ee314d6930881602962bfaeb81778b17314e1cf5.zip
fixed fetch of empty records
(This used to be commit 037516f1362c8d64da1d47a0cdaf83198d3eaeaf)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/dbwrap_ctdb.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/source3/lib/dbwrap_ctdb.c b/source3/lib/dbwrap_ctdb.c
index 0de61ceb6a..a6bda8e403 100644
--- a/source3/lib/dbwrap_ctdb.c
+++ b/source3/lib/dbwrap_ctdb.c
@@ -321,12 +321,16 @@ static int db_ctdb_transaction_fetch(struct db_ctdb_ctx *db,
if (data->dptr != NULL) {
uint8_t *oldptr = (uint8_t *)data->dptr;
data->dsize -= sizeof(struct ctdb_ltdb_header);
- data->dptr = (uint8 *)
- talloc_memdup(
- mem_ctx, data->dptr+sizeof(struct ctdb_ltdb_header),
- data->dsize);
+ if (data->dsize == 0) {
+ data->dptr = NULL;
+ } else {
+ data->dptr = (uint8 *)
+ talloc_memdup(
+ mem_ctx, data->dptr+sizeof(struct ctdb_ltdb_header),
+ data->dsize);
+ }
SAFE_FREE(oldptr);
- if (data->dptr == NULL) {
+ if (data->dptr == NULL && data->dsize != 0) {
return -1;
}
}
@@ -439,7 +443,8 @@ static int db_ctdb_transaction_store(struct db_ctdb_transaction_handle *h,
}
}
- rec.dptr = talloc_size(tmp_ctx, data.dsize + sizeof(struct ctdb_ltdb_header));
+ rec.dsize = data.dsize + sizeof(struct ctdb_ltdb_header);
+ rec.dptr = talloc_size(tmp_ctx, rec.dsize);
if (rec.dptr == NULL) {
DEBUG(0,(__location__ " Failed to alloc record\n"));
talloc_free(tmp_ctx);