From 76796e212c0f1dc7587be138daac9c4ef093db4b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 16 Dec 2005 00:10:59 +0000 Subject: 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 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source3/libsmb/clilist.c') 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; -- cgit