Wrong call to Wide2AnsiMoveProc in GetLocaleStr with fpc 2.6.4 [PATCH]
Original Reporter info from Mantis: luca @olivluca
-
Reporter name: Luca Olivetti
Original Reporter info from Mantis: luca @olivluca
- Reporter name: Luca Olivetti
Description:
in components/lazutils/winlazutf8.inc, function GetLocaleStr, when compiled with fpc 2.6.4 the call to Wide2AnsiMoveProc is wrong:
widestringmanager.Wide2AnsiMoveProc(PWideChar(@buf[0]),Result,CP_UTF8);
the third paramater is the length, so the call should be
widestringmanager.Wide2AnsiMoveProc(PWideChar(@buf[0]),Result,L-1);
since CP_UTF8 is 65001 this leads to sigsev and other unpredictable errors.
Steps to reproduce:
I discovered this when connecting to a virtual machine via RDP. The connection/disconnection triggers an WM_SETTINGCHANGE message, which then calls Application.IntfSettingsChange -> GetFormatSettingsUTF8 -> GetLocaleFormatSettingsUTF8 -> GetLocaleStr
Mantis conversion info:
- Mantis ID: 31272
- Version: 1.6.2
- Fixed in revision: 54005 (#bb1a32ec)