mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-02 09:09:47 +01:00
* fix remaining search handle leaks in Dos.FSearch - fix for bug #30896
git-svn-id: trunk@34910 -
This commit is contained in:
parent
67570a6262
commit
1e6ee7f3c7
@ -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;
|
||||
|
||||
|
||||
|
||||
@ -1001,6 +1001,7 @@ begin
|
||||
fsearch:=path;
|
||||
exit;
|
||||
end;
|
||||
findclose(s);
|
||||
{ allow slash as backslash }
|
||||
DoDirSeparators(dirlist);
|
||||
repeat
|
||||
|
||||
@ -783,6 +783,7 @@ begin
|
||||
fsearch:=path;
|
||||
exit;
|
||||
end;
|
||||
findclose(s);
|
||||
{ allow slash as backslash }
|
||||
DoDirSeparators(dirlist);
|
||||
repeat
|
||||
|
||||
@ -370,6 +370,7 @@ begin
|
||||
fsearch:=path;
|
||||
exit;
|
||||
end;
|
||||
findclose(s);
|
||||
{ allow backslash as slash }
|
||||
DoDirSeparators(dirlist);
|
||||
repeat
|
||||
|
||||
@ -472,6 +472,7 @@ begin
|
||||
fsearch:=path;
|
||||
exit;
|
||||
end;
|
||||
findclose(s);
|
||||
{ allow backslash as slash }
|
||||
DoDirSeparators(dirlist);
|
||||
repeat
|
||||
|
||||
@ -126,6 +126,7 @@ begin
|
||||
fsearch:=path;
|
||||
exit;
|
||||
end;
|
||||
findclose(s);
|
||||
{ allow slash as backslash }
|
||||
DoDirSeparators(dirlist);
|
||||
repeat
|
||||
|
||||
@ -649,6 +649,7 @@ begin
|
||||
fsearch:=path;
|
||||
exit;
|
||||
end;
|
||||
findclose(s);
|
||||
{ allow slash as backslash }
|
||||
DoDirSeparators(dirlist);
|
||||
repeat
|
||||
|
||||
@ -568,6 +568,7 @@ begin
|
||||
fsearch:=path;
|
||||
exit;
|
||||
end;
|
||||
findclose(s);
|
||||
{ allow slash as backslash }
|
||||
DoDirSeparators(dirlist);
|
||||
repeat
|
||||
|
||||
@ -818,6 +818,7 @@ begin
|
||||
fsearch:=path;
|
||||
exit;
|
||||
end;
|
||||
findclose(s);
|
||||
{ allow slash as backslash }
|
||||
DoDirSeparators(dirlist);
|
||||
repeat
|
||||
|
||||
@ -424,6 +424,7 @@ begin
|
||||
fsearch:=path;
|
||||
exit;
|
||||
end;
|
||||
findclose(s);
|
||||
{ allow slash as backslash }
|
||||
DoDirSeparators(dirlist);
|
||||
repeat
|
||||
|
||||
Loading…
Reference in New Issue
Block a user