* fix remaining search handle leaks in Dos.FSearch - fix for bug #30896

git-svn-id: trunk@34910 -
This commit is contained in:
Tomas Hajny 2016-11-17 22:05:17 +00:00
parent 67570a6262
commit 1e6ee7f3c7
10 changed files with 44 additions and 20 deletions

View File

@ -804,27 +804,42 @@ var
begin
{ No wildcards allowed in these things }
if (pos('?',path)<>0) or (pos('*',path)<>0) or (path='') then
FSearch:=''
else begin
repeat
p1:=pos(';',dirlist);
if p1<>0 then begin
newdir:=Copy(dirlist,1,p1-1);
Delete(dirlist,1,p1);
end else begin
newdir:=dirlist;
dirlist:='';
end;
if (newdir<>'') and (not (newdir[length(newdir)] in ['/',':'])) then
newdir:=newdir+'/';
FindFirst(newdir+path,anyfile,tmpSR);
if doserror=0 then
newdir:=newdir+path
else
newdir:='';
until (dirlist='') or (newdir<>'');
FSearch:=newdir;
begin
FSearch:='';
exit;
end;
{ check if the file specified exists }
findfirst(path,anyfile and not(directory), tmpSR);
if doserror=0 then
begin
findclose(tmpSR);
fsearch:=path;
exit;
end;
findclose(tmpSR);
repeat
p1:=pos(';',dirlist);
if p1<>0 then
begin
newdir:=Copy(dirlist,1,p1-1);
Delete(dirlist,1,p1);
end
else
begin
newdir:=dirlist;
dirlist:='';
end;
if (newdir<>'') and (not (newdir[length(newdir)] in [DirectorySeparator, DriveSeparator])) then
newdir:=newdir+DirectorySeparator;
FindFirst(newdir+path,anyfile and not(directory),tmpSR);
if doserror=0 then
newdir:=newdir+path
else
newdir:='';
findclose(tmpSR);
until (dirlist='') or (newdir<>'');
FSearch:=newdir;
end;

View File

@ -1001,6 +1001,7 @@ begin
fsearch:=path;
exit;
end;
findclose(s);
{ allow slash as backslash }
DoDirSeparators(dirlist);
repeat

View File

@ -783,6 +783,7 @@ begin
fsearch:=path;
exit;
end;
findclose(s);
{ allow slash as backslash }
DoDirSeparators(dirlist);
repeat

View File

@ -370,6 +370,7 @@ begin
fsearch:=path;
exit;
end;
findclose(s);
{ allow backslash as slash }
DoDirSeparators(dirlist);
repeat

View File

@ -472,6 +472,7 @@ begin
fsearch:=path;
exit;
end;
findclose(s);
{ allow backslash as slash }
DoDirSeparators(dirlist);
repeat

View File

@ -126,6 +126,7 @@ begin
fsearch:=path;
exit;
end;
findclose(s);
{ allow slash as backslash }
DoDirSeparators(dirlist);
repeat

View File

@ -649,6 +649,7 @@ begin
fsearch:=path;
exit;
end;
findclose(s);
{ allow slash as backslash }
DoDirSeparators(dirlist);
repeat

View File

@ -568,6 +568,7 @@ begin
fsearch:=path;
exit;
end;
findclose(s);
{ allow slash as backslash }
DoDirSeparators(dirlist);
repeat

View File

@ -818,6 +818,7 @@ begin
fsearch:=path;
exit;
end;
findclose(s);
{ allow slash as backslash }
DoDirSeparators(dirlist);
repeat

View File

@ -424,6 +424,7 @@ begin
fsearch:=path;
exit;
end;
findclose(s);
{ allow slash as backslash }
DoDirSeparators(dirlist);
repeat