s3-rpc_server: Fix null pointer derefs in rpc_pipe_open_interface().
[kai/samba.git] / source3 / rpc_server / rpc_ncacn_np.c
index 25ad8570a2864af64a601fcf021ada2993a655b0..b4602a91d5ab1bc73d617a84c6a6c31e7a1c9114 100644 (file)
@@ -770,10 +770,12 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 
-       if (cli_pipe && rpccli_is_connected(*cli_pipe)) {
-               return NT_STATUS_OK;
-       } else {
-               TALLOC_FREE(*cli_pipe);
+       if (cli_pipe != NULL) {
+               if (rpccli_is_connected(*cli_pipe)) {
+                       return NT_STATUS_OK;
+               } else {
+                       TALLOC_FREE(*cli_pipe);
+               }
        }
 
        tmp_ctx = talloc_stackframe();
@@ -827,7 +829,7 @@ NTSTATUS rpc_pipe_open_interface(TALLOC_CTX *mem_ctx,
 
        status = NT_STATUS_OK;
 done:
-       if (NT_STATUS_IS_OK(status)) {
+       if (NT_STATUS_IS_OK(status) && cli_pipe != NULL) {
                *cli_pipe = talloc_move(mem_ctx, &cli);
        }
        TALLOC_FREE(tmp_ctx);