[PATCH 2/2] gdiplus: Guard initialization of installed font collection.
Jeff Smith
whydoubt at gmail.com
Thu Nov 19 10:35:57 CST 2020
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
Without this GdipNewInstalledFontCollection may return a partial
collection, if called while another thread is initializing it.
dlls/gdiplus/font.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/dlls/gdiplus/font.c b/dlls/gdiplus/font.c
index 4301fa3aaa3..05663b71aad 100644
--- a/dlls/gdiplus/font.c
+++ b/dlls/gdiplus/font.c
@@ -117,6 +117,15 @@ typedef struct
static GpFontCollection installedFontCollection = {0};
+static CRITICAL_SECTION font_cs;
+static CRITICAL_SECTION_DEBUG critsect_debug =
+{
+ 0, 0, &font_cs,
+ { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": font_cs") }
+};
+static CRITICAL_SECTION font_cs = { &critsect_debug, -1, 0, 0, 0, 0 };
+
/*******************************************************************************
* GdipCreateFont [GDIPLUS.@]
*
@@ -1648,6 +1657,7 @@ GpStatus WINGDIPAPI GdipNewInstalledFontCollection(
if (!fontCollection)
return InvalidParameter;
+ EnterCriticalSection( &font_cs );
if (installedFontCollection.count == 0)
{
struct add_font_param param;
@@ -1665,11 +1675,13 @@ GpStatus WINGDIPAPI GdipNewInstalledFontCollection(
{
free_installed_fonts();
DeleteDC(param.hdc);
+ LeaveCriticalSection( &font_cs );
return param.stat;
}
DeleteDC(param.hdc);
}
+ LeaveCriticalSection( &font_cs );
*fontCollection = &installedFontCollection;
--
2.23.0
More information about the wine-devel
mailing list