From 1d651a8d5847c1ecd87d5f1bbfc7714e078d60f2 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Tue, 9 Jul 2019 16:02:47 +0000 Subject: s3/lib: clang: Fix 'Acces to field results in a deref of a null pointer' Fixes: source3/lib/ctdbd_conn.c:415:6: warning: Access to field 'operation' results in a dereference of a null pointer (loaded from variable 'hdr') <--[clang] if (hdr->operation == CTDB_REQ_MESSAGE) { Signed-off-by: Noel Power Reviewed-by: Gary Lockyer --- source3/lib/ctdbd_conn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/ctdbd_conn.c b/source3/lib/ctdbd_conn.c index d5fac572d3c..0df404c4ff2 100644 --- a/source3/lib/ctdbd_conn.c +++ b/source3/lib/ctdbd_conn.c @@ -398,15 +398,16 @@ static int ctdb_read_packet(int fd, int timeout, TALLOC_CTX *mem_ctx, static int ctdb_read_req(struct ctdbd_connection *conn, uint32_t reqid, TALLOC_CTX *mem_ctx, struct ctdb_req_header **result) { - struct ctdb_req_header *hdr; + struct ctdb_req_header *hdr = NULL; int ret; next_pkt: ret = ctdb_read_packet(conn->fd, conn->timeout, mem_ctx, &hdr); - if (ret != 0) { + if (hdr == NULL || ret != 0) { DBG_ERR("ctdb_read_packet failed: %s\n", strerror(ret)); cluster_fatal("failed to read data from ctdbd\n"); + return -1; } DEBUG(11, ("Received ctdb packet\n")); -- cgit v1.2.1