Nikolay Sivov : dwrite: Use safer method to set per-factory EUDC collection reference.
Alexandre Julliard
julliard at winehq.org
Wed Aug 23 19:54:08 CDT 2017
Module: wine
Branch: master
Commit: f85def77654cecdcb78ac77e7a738c6601c4f0a2
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f85def77654cecdcb78ac77e7a738c6601c4f0a2
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Tue Aug 22 12:42:13 2017 +0300
dwrite: Use safer method to set per-factory EUDC collection reference.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/dwrite/main.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/dlls/dwrite/main.c b/dlls/dwrite/main.c
index 3d72a02..555860a 100644
--- a/dlls/dwrite/main.c
+++ b/dlls/dwrite/main.c
@@ -1272,10 +1272,20 @@ static HRESULT WINAPI dwritefactory1_GetEudcFontCollection(IDWriteFactory5 *ifac
if (This->eudc_collection)
IDWriteFontCollection1_AddRef(This->eudc_collection);
- else
- hr = get_eudc_fontcollection(iface, &This->eudc_collection);
+ else {
+ IDWriteFontCollection1 *eudc_collection;
+
+ if (FAILED(hr = get_eudc_fontcollection(iface, &eudc_collection))) {
+ *collection = NULL;
+ WARN("Failed to get EUDC collection, hr %#x.\n", hr);
+ return hr;
+ }
+
+ if (InterlockedCompareExchangePointer((void **)&This->eudc_collection, eudc_collection, NULL))
+ IDWriteFontCollection1_Release(eudc_collection);
+ }
- *collection = (IDWriteFontCollection*)This->eudc_collection;
+ *collection = (IDWriteFontCollection *)This->eudc_collection;
return hr;
}
@@ -1801,8 +1811,7 @@ void factory_detach_fontcollection(IDWriteFactory5 *iface, IDWriteFontCollection
{
struct dwritefactory *factory = impl_from_IDWriteFactory5(iface);
InterlockedCompareExchangePointer((void **)&factory->system_collection, NULL, collection);
- if (factory->eudc_collection == collection)
- factory->eudc_collection = NULL;
+ InterlockedCompareExchangePointer((void **)&factory->eudc_collection, NULL, collection);
IDWriteFactory5_Release(iface);
}
More information about the wine-cvs
mailing list