summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}
/****************************************************************************