Fix crash when using list or tree control in ANSI build of wxMSW

Calling SystemParametersInfoForDpi() with LOGFONTA parameter corrupted
the stack because this function only accepts LOGFONTW, i.e. it wrote
twice as much data into the provided buffer as the caller expected.

This could be fixed by allocating a temporary wide buffer and converting
back, but this doesn't seem to be worth it, so just disable the use of
the DPI-specific function in the ANSI build.

Closes #19002.
This commit is contained in:
Vadim Zeitlin
2020-12-09 14:57:21 +01:00
parent 6b488723a8
commit e99992b42d

View File

@@ -4807,7 +4807,12 @@ int wxGetSystemMetrics(int nIndex, const wxWindow* win)
/*extern*/
bool wxSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni, const wxWindow* win)
{
#if wxUSE_DYNLIB_CLASS
// Note that we can't use SystemParametersInfoForDpi() in non-Unicode build
// because it always works with wide strings and we'd have to check for all
// uiAction values corresponding to strings and use a temporary wide buffer
// for them, and convert the returned value to ANSI after the call. Instead
// of doing all this, just don't use it at all in the deprecated ANSI build.
#if wxUSE_DYNLIB_CLASS && wxUSE_UNICODE
const wxWindow* window = (!win && wxTheApp) ? wxTheApp->GetTopWindow() : win;
if ( window )