summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-11-27 03:29:20 +0000
committerAndrew Tridgell <tridge@samba.org>2001-11-27 03:29:20 +0000
commit911c57403bd116405876e73913ad73efd15f659b (patch)
treea99ffd01a77d7027e4b712d424d937da40a75bed /source
parent1421f2fbcb296a894cb4e7548e0275e35e055b98 (diff)
downloadsamba-911c57403bd116405876e73913ad73efd15f659b.tar.gz
samba-911c57403bd116405876e73913ad73efd15f659b.tar.xz
samba-911c57403bd116405876e73913ad73efd15f659b.zip
prevent a memory leak of cli structures
Diffstat (limited to 'source')
-rw-r--r--source/include/client.h4
-rw-r--r--source/libsmb/clientgen.c8
2 files changed, 11 insertions, 1 deletions
diff --git a/source/include/client.h b/source/include/client.h
index 9dd41313f28..fde001813d3 100644
--- a/source/include/client.h
+++ b/source/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/source/libsmb/clientgen.c b/source/libsmb/clientgen.c
index 0e093888036..610af9cc237 100644
--- a/source/libsmb/clientgen.c
+++ b/source/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);
+ }
}