[PATCH 0/1] MR5957: win32u: fix random crash without libfreetype
without freetype, some calling return failed, so some value may not be initialized (it initialize by some failed calling and pass argument by point of it), it would cause random crash! Signed-off-by: Fan WenJie <fanwj(a)mail.ustc.edu.cn> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5957
From: Fan WenJie <fanwj(a)mail.ustc.edu.cn> Signed-off-by: Fan WenJie <fanwj(a)mail.ustc.edu.cn> --- dlls/win32u/sysparams.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index 9a06db2c7f6..9a885d182aa 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -4323,13 +4323,16 @@ LONG get_char_dimensions( HDC hdc, TEXTMETRICW *metric, int *height ) 'r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H', 'I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}; - if (metric && !NtGdiGetTextMetricsW( hdc, metric, 0 )) return 0; + if (metric && !NtGdiGetTextMetricsW( hdc, metric, 0 )) goto fail; if (!NtGdiGetTextExtentExW( hdc, abcdW, ARRAYSIZE(abcdW), 0, NULL, NULL, &sz, 0 )) - return 0; + goto fail; if (height) *height = sz.cy; return (sz.cx / 26 + 1) / 2; +fail: + if (height) *height = 1; + return 0; } /* get text metrics and/or "average" char width of the specified logfont @@ -4340,6 +4343,7 @@ static void get_text_metr_size( HDC hdc, LOGFONTW *lf, TEXTMETRICW *metric, UINT TEXTMETRICW tm; UINT ret; if (!metric) metric = &tm; + memset(metric, 0, sizeof(*metric)); hfont = NtGdiHfontCreate( lf, sizeof(*lf), 0, 0, NULL ); if (!hfont || !(hfontsav = NtGdiSelectFont( hdc, hfont ))) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/5957
participants (2)
-
Fan WenJie -
Fan WenJie (@fanwenjie)