]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/lib: clang: Fix 'Acces to field results in a deref of a null pointer'
authorNoel Power <noel.power@suse.com>
Tue, 9 Jul 2019 16:02:47 +0000 (16:02 +0000)
committerGary Lockyer <gary@samba.org>
Wed, 24 Jul 2019 21:33:21 +0000 (21:33 +0000)
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 <noel.power@suse.com>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
source3/lib/ctdbd_conn.c

index d5fac572d3c94402798c63d2fcff999578502ab1..0df404c4ff2b64919823df2cb7fe21961458bb16 100644 (file)
@@ -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"));