summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-12-16 00:10:59 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:05:51 -0500
commit76796e212c0f1dc7587be138daac9c4ef093db4b (patch)
tree4363d0d1eb2a63e37f541f282e107fab7f07c311
parentf6e81060763f238ab32b95c6cbe069ae8234ba19 (diff)
downloadsamba-76796e212c0f1dc7587be138daac9c4ef093db4b.tar.gz
samba-76796e212c0f1dc7587be138daac9c4ef093db4b.tar.bz2
samba-76796e212c0f1dc7587be138daac9c4ef093db4b.zip
r12275: Fix memory leak found by Mikhail Kshevetskiy <kl@laska.dorms.spbu.ru>
and followed up by derrell@samba.org. Jeremy. (This used to be commit 5cab88f1444177129bb5521ccc4afd8869e9bf25)
-rw-r--r--source3/libsmb/clilist.c16
-rw-r--r--source3/rpc_client/cli_pipe.c2
2 files changed, 16 insertions, 2 deletions
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index e09a6514ad..252dafcfa8 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -271,6 +271,10 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
it gives ERRSRV/ERRerror temprarily */
uint8 eclass;
uint32 ecode;
+
+ SAFE_FREE(rdata);
+ SAFE_FREE(rparam);
+
cli_dos_error(cli, &eclass, &ecode);
if (eclass != ERRSRV || ecode != ERRerror)
break;
@@ -278,8 +282,11 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
continue;
}
- if (cli_is_error(cli) || !rdata || !rparam)
+ if (cli_is_error(cli) || !rdata || !rparam) {
+ SAFE_FREE(rdata);
+ SAFE_FREE(rparam);
break;
+ }
if (total_received == -1)
total_received = 0;
@@ -297,8 +304,11 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
ff_lastname = SVAL(p,6);
}
- if (ff_searchcount == 0)
+ if (ff_searchcount == 0) {
+ SAFE_FREE(rdata);
+ SAFE_FREE(rparam);
break;
+ }
/* point to the data bytes */
p = rdata;
@@ -332,6 +342,8 @@ int cli_list_new(struct cli_state *cli,const char *Mask,uint16 attribute,
if (!tdl) {
DEBUG(0,("cli_list_new: Failed to expand dirlist\n"));
+ SAFE_FREE(rdata);
+ SAFE_FREE(rparam);
break;
} else {
dirlist = tdl;
diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c
index e1143e6342..23c66acf26 100644
--- a/source3/rpc_client/cli_pipe.c
+++ b/source3/rpc_client/cli_pipe.c
@@ -789,6 +789,8 @@ static NTSTATUS rpc_api_pipe(struct rpc_pipe_client *cli,
(unsigned int)cli->fnum,
cli_errstr(cli->cli)));
ret = cli_get_nt_error(cli->cli);
+ SAFE_FREE(rparam);
+ SAFE_FREE(prdata);
goto err;
}