mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 05:49:12 +02:00
* Prevent file handle leak
This commit is contained in:
parent
e79f5ef577
commit
c3339e9a51
@ -514,9 +514,12 @@ begin
|
|||||||
(which we can by definition) }
|
(which we can by definition) }
|
||||||
fd:=FileOpenNoLocking(FileName,ShareMode);
|
fd:=FileOpenNoLocking(FileName,ShareMode);
|
||||||
{ the file exists, check whether our locking request is compatible }
|
{ the file exists, check whether our locking request is compatible }
|
||||||
if (fd>=0) and ((ShareMode and fmShareNoLocking)=0) then
|
if (fd>=0) then
|
||||||
begin
|
begin
|
||||||
Result:=DoFileLocking(fd,ShareMode);
|
if ((ShareMode and fmShareNoLocking)=0) then
|
||||||
|
Result:=DoFileLocking(fd,ShareMode)
|
||||||
|
else
|
||||||
|
Result:=0;
|
||||||
FileClose(fd);
|
FileClose(fd);
|
||||||
{ Can't lock -> abort }
|
{ Can't lock -> abort }
|
||||||
if Result<0 then
|
if Result<0 then
|
||||||
@ -524,7 +527,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
{ now create the file }
|
{ now create the file }
|
||||||
Result:=FileCreate(FileName,Rights);
|
Result:=FileCreate(FileName,Rights);
|
||||||
if (ShareMode and fmShareNoLocking)=0 then
|
if ((ShareMode and fmShareNoLocking)=0) then
|
||||||
Result:=DoFileLocking(Result,ShareMode);
|
Result:=DoFileLocking(Result,ShareMode);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user