diff options
-rw-r--r-- | source3/include/client.h | 4 | ||||
-rw-r--r-- | source3/libsmb/clientgen.c | 8 |
2 files changed, 11 insertions, 1 deletions
diff --git a/source3/include/client.h b/source3/include/client.h index 9dd41313f2..fde001813d 100644 --- a/source3/include/client.h +++ b/source3/include/client.h @@ -138,6 +138,10 @@ struct cli_state { BOOL (*oplock_handler)(struct cli_state *cli, int fnum, unsigned char level); BOOL force_dos_errors; + + /* was this structure allocated by cli_initialise? If so, then + free in cli_shutdown() */ + BOOL allocated; }; #endif /* _CLIENT_H */ diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c index 0e09388803..610af9cc23 100644 --- a/source3/libsmb/clientgen.c +++ b/source3/libsmb/clientgen.c @@ -217,6 +217,7 @@ struct cli_state *cli_initialise(struct cli_state *cli) cli->nt_pipe_fnum = 0; cli->initialised = 1; + cli->allocated = alloced_cli; return cli; @@ -238,6 +239,7 @@ shutdown a client structure ****************************************************************************/ void cli_shutdown(struct cli_state *cli) { + BOOL allocated; SAFE_FREE(cli->outbuf); SAFE_FREE(cli->inbuf); @@ -252,7 +254,11 @@ void cli_shutdown(struct cli_state *cli) #endif /* WITH_SSL */ if (cli->fd != -1) close(cli->fd); - memset(cli, 0, sizeof(*cli)); + allocated = cli->allocated; + ZERO_STRUCTP(cli); + if (allocated) { + free(cli); + } } |