瀏覽代碼

SharedGraphics: Font::load_from_file() forgot to close() the font file.

Andreas Kling 6 年之前
父節點
當前提交
9da9cce4f7
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      SharedGraphics/Font.cpp

+ 7 - 1
SharedGraphics/Font.cpp

@@ -154,12 +154,18 @@ RetainPtr<Font> Font::load_from_file(const String& path)
     }
     }
 
 
     auto* mapped_file = (byte*)mmap(nullptr, 4096 * 3, PROT_READ, MAP_SHARED, fd, 0);
     auto* mapped_file = (byte*)mmap(nullptr, 4096 * 3, PROT_READ, MAP_SHARED, fd, 0);
-    if (mapped_file == MAP_FAILED)
+    if (mapped_file == MAP_FAILED) {
+        int rc = close(fd);
+        ASSERT(rc == 0);
         return nullptr;
         return nullptr;
+    }
 
 
     auto font = load_from_memory(mapped_file);
     auto font = load_from_memory(mapped_file);
     int rc = munmap(mapped_file, 4096 * 3);
     int rc = munmap(mapped_file, 4096 * 3);
     ASSERT(rc == 0);
     ASSERT(rc == 0);
+
+    rc = close(fd);
+    ASSERT(rc == 0);
     return font;
     return font;
 }
 }