s3/libsmb: clang: Fix 'the left operand of '-' is a garbage value'
authorNoel Power <noel.power@suse.com>
Tue, 13 Aug 2019 14:57:22 +0000 (15:57 +0100)
committerRalph Boehme <slow@samba.org>
Tue, 22 Oct 2019 18:48:43 +0000 (18:48 +0000)
Fixes:

source3/libsmb/clifile.c:360:19: warning: The left operand of '-' is a garbage value <--[clang]
        if (data[num_data-1] != '\0') {
                 ~~~~~~~~^
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Oct 22 18:48:43 UTC 2019 on sn-devel-184

source3/libsmb/clifile.c

index 987b04d0a661f6c3a2e82164d01d4432ed016e84..dd08b0e30f35fa3fe8347c4f7d0ce026a51ac900 100644 (file)
@@ -344,7 +344,7 @@ static void cli_posix_readlink_done(struct tevent_req *subreq)
                req, struct cli_posix_readlink_state);
        NTSTATUS status;
        uint8_t *data = NULL;
-       uint32_t num_data;
+       uint32_t num_data = 0;
        charset_t charset;
        size_t converted_size;
        bool ok;
@@ -357,7 +357,7 @@ static void cli_posix_readlink_done(struct tevent_req *subreq)
        /*
         * num_data is > 1, we've given 1 as minimum to cli_qpathinfo_send
         */
-       if (data[num_data-1] != '\0') {
+       if (data == NULL || data[num_data-1] != '\0') {
                tevent_req_nterror(req, NT_STATUS_DATA_ERROR);
                return;
        }