s3/libsmb: clang: Fix 'Dereference of undefined pointer value'
authorNoel Power <noel.power@suse.com>
Tue, 13 Aug 2019 14:27:35 +0000 (15:27 +0100)
committerRalph Boehme <slow@samba.org>
Tue, 22 Oct 2019 17:28:27 +0000 (17:28 +0000)
Fixes:

source3/libsmb/clidfs.c:350:3: warning: Dereference of undefined pointer value <--[clang]
                DLIST_ADD_END(referring_cli, cli);
                ^
1 warning generated.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/libsmb/clidfs.c

index f617307bb033c94120f864e81fce32266ce3b6ac..ba851f3f4716160845bd77d8ef68cdf52e9d5b92 100644 (file)
@@ -333,7 +333,7 @@ static NTSTATUS cli_cm_connect(TALLOC_CTX *ctx,
                               int name_type,
                               struct cli_state **pcli)
 {
-       struct cli_state *cli;
+       struct cli_state *cli = NULL;
        NTSTATUS status;
 
        status = do_connect(ctx, server, share,
@@ -345,6 +345,14 @@ static NTSTATUS cli_cm_connect(TALLOC_CTX *ctx,
                return status;
        }
 
+       /*
+        * This can't happen, this test is to satisfy static
+        * checkers (clang)
+        */
+       if (cli == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+
        /* Enter into the list. */
        if (referring_cli) {
                DLIST_ADD_END(referring_cli, cli);