diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-11-27 03:29:20 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-11-27 03:29:20 +0000 |
commit | 701ecfc7a0a944844cadfd0b2c19f104ab7984b0 (patch) | |
tree | d7fa8d7a7630eec79b8fb2f5b8c49fba79e1136d /source3 | |
parent | 097d46653632855edd429fb8cd44d80f3e30c86c (diff) | |
download | samba-701ecfc7a0a944844cadfd0b2c19f104ab7984b0.tar.gz samba-701ecfc7a0a944844cadfd0b2c19f104ab7984b0.tar.bz2 samba-701ecfc7a0a944844cadfd0b2c19f104ab7984b0.zip |
prevent a memory leak of cli structures
(This used to be commit 911c57403bd116405876e73913ad73efd15f659b)
Diffstat (limited to 'source3')
-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); + } } |