Browse Source

* Fixed file handle leak when creating GUIDs

git-svn-id: trunk@11120 -
michael 17 years ago
parent
commit
48bf280781
1 changed files with 4 additions and 4 deletions
  1. 4 4
      rtl/linux/suuid.inc

+ 4 - 4
rtl/linux/suuid.inc

@@ -61,15 +61,15 @@ begin
   fd:=FileOpen(KernelUUID,fmOpenRead);
   fd:=FileOpen(KernelUUID,fmOpenRead);
   Result:=(Fd>=0);
   Result:=(Fd>=0);
   if Result then
   if Result then
-    begin
+    try
     SetLength(S,UUIDLen);
     SetLength(S,UUIDLen);
     SetLength(S,FileRead(fd,S[1],UUIDLen));
     SetLength(S,FileRead(fd,S[1],UUIDLen));
     Result:=(Length(S)=UUIDLen);
     Result:=(Length(S)=UUIDLen);
     If Result then
     If Result then
-      begin
       GUID:=StringToGUID('{'+S+'}');
       GUID:=StringToGUID('{'+S+'}');
-      //Writeln('Kernel ID = ',GuidToString(GUID));
-      end;
+    finally
+      FileClose(FD);  
+    end;
     end;
     end;
 end;
 end;