Skip to content

win32u: Avoid using uninitialized variable.

Ruslan Garipov requested to merge ruslangaripov/wine:fix/uninit_var into master

When dlls/win32u fails to load/initialize the `FreeType font library', a device context object ends up with the only GDI driver attached -- null_driver. The latter implements the pGetTextMetrics callback function as do-nothing code. This causes the NtGdiGetTextMetricsW() function to fail not modifying fields of its metrics argument. In result the normalize_nonclientmetrics() ends up with uninitialized tm local variable after call to the get_text_metr_size() function. Using uninitialized fields of the TEXTMETRICW structure gives unpredictable results.

This memset(3)'s the tm structure before using. After that, even if we failed to load the `FreeType font library', the `CaptionHeight', `SmCaptionHeight' and `MenuHeight' metrics keep their current values (the normalize_nonclientmetrics() function is called after get_twips_entry() callback function, thus value of an entry should not be negative).

Merge request reports

Loading