* Prevent file handle leak

This commit is contained in:
Michaël Van Canneyt 2024-01-28 11:19:51 +01:00
parent e79f5ef577
commit c3339e9a51

View File

@ -514,9 +514,12 @@ begin
(which we can by definition) }
fd:=FileOpenNoLocking(FileName,ShareMode);
{ the file exists, check whether our locking request is compatible }
if (fd>=0) and ((ShareMode and fmShareNoLocking)=0) then
if (fd>=0) then
begin
Result:=DoFileLocking(fd,ShareMode);
if ((ShareMode and fmShareNoLocking)=0) then
Result:=DoFileLocking(fd,ShareMode)
else
Result:=0;
FileClose(fd);
{ Can't lock -> abort }
if Result<0 then
@ -524,7 +527,7 @@ begin
end;
{ now create the file }
Result:=FileCreate(FileName,Rights);
if (ShareMode and fmShareNoLocking)=0 then
if ((ShareMode and fmShareNoLocking)=0) then
Result:=DoFileLocking(Result,ShareMode);
end;