summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-08-06 02:18:40 +0000
committerTim Potter <tpot@samba.org>2001-08-06 02:18:40 +0000
commit9f08cea054e7c2a3fd3b32d9c6711a269704d20b (patch)
tree7f1cb2c8933f38357c5045511ff602fc473aa4b4
parent54fc7e1abaff6403843235e1ab06edce14f5fa7b (diff)
downloadsamba-9f08cea054e7c2a3fd3b32d9c6711a269704d20b.tar.gz
samba-9f08cea054e7c2a3fd3b32d9c6711a269704d20b.tar.bz2
samba-9f08cea054e7c2a3fd3b32d9c6711a269704d20b.zip
Cleaned up error handling in cli_initialise() to fix a memleak found by
Claudia Moroder <claudiamoroder@st-ulrich.suedtirol.net> (This used to be commit b5373f4b59cfe1cffe915e5d4eb29ed83fe99ba6)
-rw-r--r--source3/libsmb/clientgen.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index e9f55850ac..79fa224e8f 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/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;
}
/****************************************************************************