summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2>2008-05-29 12:52:37 +0000
committermichael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2>2008-05-29 12:52:37 +0000
commit4069a91915e3775c9e5972c1a030a39f520c0331 (patch)
treec8bf4802cfa3ff1f64eb792f497a867fde9434d4
parent345056ab75e85f1bd318a5920522659afe4e27e7 (diff)
downloadfpc-4069a91915e3775c9e5972c1a030a39f520c0331.tar.gz
Merged revisions 11120-11121 via svnmerge from
svn+ssh://svn.freepascal.org/FPC/svn/fpc/trunk ........ r11120 | michael | 2008-05-29 14:41:22 +0200 (Thu, 29 May 2008) | 1 line * Fixed file handle leak when creating GUIDs ........ r11121 | michael | 2008-05-29 14:42:42 +0200 (Thu, 29 May 2008) | 1 line * Fixed file handle leak when creating GUIDs ........ git-svn-id: http://svn.freepascal.org/svn/fpc/branches/fixes_2_2@11122 3ad0048d-3df7-0310-abae-a5850022a9f2
-rw-r--r--rtl/linux/suuid.inc17
1 files changed, 8 insertions, 9 deletions
diff --git a/rtl/linux/suuid.inc b/rtl/linux/suuid.inc
index 99e8dccb82..e0d2faebf6 100644
--- a/rtl/linux/suuid.inc
+++ b/rtl/linux/suuid.inc
@@ -61,15 +61,14 @@ begin
fd:=FileOpen(KernelUUID,fmOpenRead);
Result:=(Fd>=0);
if Result then
- begin
- SetLength(S,UUIDLen);
- SetLength(S,FileRead(fd,S[1],UUIDLen));
- Result:=(Length(S)=UUIDLen);
- If Result then
- begin
- GUID:=StringToGUID('{'+S+'}');
- //Writeln('Kernel ID = ',GuidToString(GUID));
- end;
+ try
+ SetLength(S,UUIDLen);
+ SetLength(S,FileRead(fd,S[1],UUIDLen));
+ Result:=(Length(S)=UUIDLen);
+ If Result then
+ GUID:=StringToGUID('{'+S+'}');
+ finally
+ FileClose(FD);
end;
end;