Ver Fonte

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: branches/fixes_2_2@11122 -

michael há 17 anos atrás
pai
commit
c3f7611f81
1 ficheiros alterados com 8 adições e 9 exclusões
  1. 8 9
      rtl/linux/suuid.inc

+ 8 - 9
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;