--- samba/source/libsmb/clientgen.c.orig	Thu Dec 18 15:12:44 2003
+++ samba/source/libsmb/clientgen.c	Fri Dec 19 08:31:19 2003
@@ -338,6 +338,7 @@ close the session
 
 void cli_nt_session_close(struct cli_state *cli)
 {
+	if (cli != NULL) {
 	if (cli->ntlmssp_pipe_state) {
 		ntlmssp_end(&cli->ntlmssp_pipe_state);
 	}
@@ -347,6 +348,7 @@ void cli_nt_session_close(struct cli_sta
 
 	cli->nt_pipe_fnum = 0;
 	cli->pipe_idx = -1;
+	}
 }
 
 /****************************************************************************
@@ -398,11 +400,14 @@ void cli_close_connection(struct cli_sta
 
 void cli_shutdown(struct cli_state *cli)
 {
-	BOOL allocated = cli->allocated;
+	BOOL allocated = False;
+	if (cli != NULL) {
+		allocated = cli->allocated;
 	cli_close_connection(cli);
 	ZERO_STRUCTP(cli);
 	if (allocated)
 		free(cli);
+	}
 }
 
 /****************************************************************************
