[PATCH] gdi32: Collapse relative paths inside true type fonts file names in registry.

Paul Gofman gofmanp at gmail.com
Mon Oct 7 06:19:18 CDT 2019


Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
    The motivation under this patch is fixing the crash in Halo Online which
    originates from libcef.dll with Wine Staging. The crash scenario is the
    following.

    A staging patch puts a 'Times New Roman' font replacement to
    <datadir>/fonts/times.ttf. This is the only relevant difference introduced by
    Staging. When the font file is found there, gdi32 uses wine_get_data_dir()
    for a directory prefix to construct font file name. Later libcef.dll works
    with fonts through dwrite, and somehow gets confused by a "\\..\\" inside the
    font file name which it gets with IDWriteLocalFontFileLoader_GetFilePathFromKey()
    from system font file enumerator object.

 dlls/gdi32/freetype.c | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/dlls/gdi32/freetype.c b/dlls/gdi32/freetype.c
index e3cff25b76..2f21ba40a0 100644
--- a/dlls/gdi32/freetype.c
+++ b/dlls/gdi32/freetype.c
@@ -3168,11 +3168,33 @@ static void update_reg_entries(void)
             HeapFree( GetProcessHeap(), 0, buffer );
 
             if (path)
-                file = path;
+            {
+                len = GetFullPathNameW(path, 0, NULL, NULL);
+                if (!(file = HeapAlloc(GetProcessHeap(), 0, len * sizeof(*file))))
+                {
+                    HeapFree(GetProcessHeap(), 0, path);
+                    HeapFree(GetProcessHeap(), 0, valueW);
+                    continue;
+                }
+                if (GetFullPathNameW(path, len, file, NULL) != len - 1)
+                {
+                    ERR("Could not get full path name, path %s.\n", debugstr_w(path));
+                    HeapFree(GetProcessHeap(), 0, file);
+                    HeapFree(GetProcessHeap(), 0, path);
+                    HeapFree(GetProcessHeap(), 0, valueW);
+                    continue;
+                }
+                HeapFree(GetProcessHeap(), 0, path);
+                path = file;
+            }
             else if ((file = strrchrW(face->file, '/')))
+            {
                 file++;
+            }
             else
+            {
                 file = face->file;
+            }
 
             len = strlenW(file) + 1;
             RegSetValueExW(winnt_key, valueW, 0, REG_SZ, (BYTE*)file, len * sizeof(WCHAR));
-- 
2.21.0




More information about the wine-devel mailing list