diff options
author | Tim Potter <tpot@samba.org> | 2001-08-06 02:18:40 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2001-08-06 02:18:40 +0000 |
commit | b5373f4b59cfe1cffe915e5d4eb29ed83fe99ba6 (patch) | |
tree | e9d47133db28f1993f212c7d10cc6c6e5c6e0715 | |
parent | 99ce277fc857069f86824a3c0cd8012f4cede1b6 (diff) | |
download | samba-b5373f4b59cfe1cffe915e5d4eb29ed83fe99ba6.tar.gz samba-b5373f4b59cfe1cffe915e5d4eb29ed83fe99ba6.tar.xz samba-b5373f4b59cfe1cffe915e5d4eb29ed83fe99ba6.zip |
Cleaned up error handling in cli_initialise() to fix a memleak found by
Claudia Moroder <claudiamoroder@st-ulrich.suedtirol.net>
-rw-r--r-- | source/libsmb/clientgen.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/source/libsmb/clientgen.c b/source/libsmb/clientgen.c index e9f55850ac1..79fa224e8f0 100644 --- a/source/libsmb/clientgen.c +++ b/source/libsmb/clientgen.c @@ -180,24 +180,28 @@ struct cli_state *cli_initialise(struct cli_state *cli) cli->oplock_handler = cli_oplock_ack; if (!cli->outbuf || !cli->inbuf) - { - return NULL; - } + goto error; - if ((cli->mem_ctx = talloc_init()) == NULL) { - free(cli->outbuf); - free(cli->inbuf); - return NULL; - } + if ((cli->mem_ctx = talloc_init()) == NULL) + goto error; - memset(cli->outbuf, '\0', cli->bufsize); - memset(cli->inbuf, '\0', cli->bufsize); + memset(cli->outbuf, 0, cli->bufsize); + memset(cli->inbuf, 0, cli->bufsize); cli->nt_pipe_fnum = 0; cli->initialised = 1; return cli; + + /* Clean up after malloc() error */ + + error: + + safe_free(cli->inbuf); + safe_free(cli->outbuf); + + return NULL; } /**************************************************************************** |