mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
SharedGraphics: Font::load_from_file() forgot to close() the font file.
This commit is contained in:
parent
1fffc0ae60
commit
9da9cce4f7
Notes:
sideshowbarker
2024-07-19 15:53:00 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/9da9cce4f75
1 changed files with 7 additions and 1 deletions
|
@ -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);
|
||||
if (mapped_file == MAP_FAILED)
|
||||
if (mapped_file == MAP_FAILED) {
|
||||
int rc = close(fd);
|
||||
ASSERT(rc == 0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto font = load_from_memory(mapped_file);
|
||||
int rc = munmap(mapped_file, 4096 * 3);
|
||||
ASSERT(rc == 0);
|
||||
|
||||
rc = close(fd);
|
||||
ASSERT(rc == 0);
|
||||
return font;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue