From 701ecfc7a0a944844cadfd0b2c19f104ab7984b0 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 27 Nov 2001 03:29:20 +0000 Subject: prevent a memory leak of cli structures (This used to be commit 911c57403bd116405876e73913ad73efd15f659b) --- source3/libsmb/clientgen.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'source3/libsmb') 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); + } } -- cgit