瀏覽代碼

* Fixed file handle leak when creating GUIDs

git-svn-id: trunk@11120 -
michael 17 年之前
父節點
當前提交
48bf280781
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      rtl/linux/suuid.inc

+ 4 - 4
rtl/linux/suuid.inc

@@ -61,15 +61,15 @@ begin
   fd:=FileOpen(KernelUUID,fmOpenRead);
   Result:=(Fd>=0);
   if Result then
-    begin
+    try
     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;
+    finally
+      FileClose(FD);  
+    end;
     end;
 end;