From 92a68af1a8473dc2a5d9d6036830f944e968606d Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 19 Mar 2018 13:38:28 +1100 Subject: [PATCH] ctdb-client: Do not try to allocate 0 sized record BUG: https://bugzilla.samba.org/show_bug.cgi?id=13356 Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- ctdb/client/client_db.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/ctdb/client/client_db.c b/ctdb/client/client_db.c index e86830e7bfb9..a0c4cfed6525 100644 --- a/ctdb/client/client_db.c +++ b/ctdb/client/client_db.c @@ -1413,14 +1413,19 @@ struct ctdb_record_handle *ctdb_fetch_lock_recv(struct tevent_req *req, offset = ctdb_ltdb_header_len(&h->header); data->dsize = h->data.dsize - offset; - data->dptr = talloc_memdup(mem_ctx, h->data.dptr + offset, - data->dsize); - if (data->dptr == NULL) { - TALLOC_FREE(state->h); - if (perr != NULL) { - *perr = ENOMEM; + if (data->dsize == 0) { + data->dptr = NULL; + } else { + data->dptr = talloc_memdup(mem_ctx, + h->data.dptr + offset, + data->dsize); + if (data->dptr == NULL) { + TALLOC_FREE(state->h); + if (perr != NULL) { + *perr = ENOMEM; + } + return NULL; } - return NULL; } } -- 2.34.1