Module: wine Branch: master Commit: b3bf30e7e21f25ca539ade9607cdaaed77067d08 URL: https://gitlab.winehq.org/wine/wine/-/commit/b3bf30e7e21f25ca539ade9607cdaae...
Author: Florian Will florian.will@gmail.com Date: Tue Feb 28 11:56:56 2023 +0100
gdiplus: Use FILE_SHARE_READ in GdipPrivateAddFontFile().
ZusiDisplay sometimes loads the same font file into two different PrivateFontCollections using two threads, so there is a race condition when the file is opened without the FILE_SHARE_READ sharing mode. The second call to GdipPrivateAddFontFile() might fail if the first one hasn't closed the file handle yet.
---
dlls/gdiplus/font.c | 2 +- dlls/gdiplus/tests/font.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c index 96d3c5630bc..bcf36a60090 100644 --- a/dlls/gdiplus/font.c +++ b/dlls/gdiplus/font.c @@ -1110,7 +1110,7 @@ GpStatus WINGDIPAPI GdipPrivateAddFontFile(GpFontCollection *collection, GDIPCON
if (!collection || !name) return InvalidParameter;
- file = CreateFileW(name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); + file = CreateFileW(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (file == INVALID_HANDLE_VALUE) return InvalidParameter;
if (!GetFileSizeEx(file, &size) || size.u.HighPart) diff --git a/dlls/gdiplus/tests/font.c b/dlls/gdiplus/tests/font.c index 7fbe619cd93..a2aea904bb1 100644 --- a/dlls/gdiplus/tests/font.c +++ b/dlls/gdiplus/tests/font.c @@ -91,7 +91,7 @@ static void test_long_name(void) ok(file != INVALID_HANDLE_VALUE, "CreateFileW failed: %ld\n", GetLastError());
stat = GdipPrivateAddFontFile(fonts, path); - todo_wine ok(stat == Ok, "GdipPrivateAddFontFile failed with open file handle: %d\n", stat); + ok(stat == Ok, "GdipPrivateAddFontFile failed with open file handle: %d\n", stat);
CloseHandle(file);