From 76796e212c0f1dc7587be138daac9c4ef093db4b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 16 Dec 2005 00:10:59 +0000 Subject: [PATCH] r12275: Fix memory leak found by Mikhail Kshevetskiy and followed up by derrell@samba.org. Jeremy. (This used to be commit 5cab88f1444177129bb5521ccc4afd8869e9bf25) --- source3/libsmb/clilist.c | 16 ++++++++++++++-- source3/rpc_client/cli_pipe.c | 2 ++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c index e09a6514ad9..252dafcfa8b 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 e1143e63423..23c66acf26e 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; } -- 2.11.4.GIT