rev 1.50 of tkWinMenu.c introduced a fix to the Tk bug #1599877, but that fix introduced the new problem:
If the toplevel's main menu contains a Cyrillic word containing underline then wish crashes when a user presses Alt+any key in that window (i.e. triggers the code looking for accelerated menu entries). The actual crash occurs in CharUpperA (user32.dll) which is called from TkWinHandleMenuEvent (WM_MENUCHAR processing).
The problem is that the current implementation (in my opinion) does two things wrong:
* it assumes wParam in that case always passes a character as a byte, but it may be a wchar_t on a Unicode system.
* it assumes an underlined character in a UTF-8 string representing the menu item label is a one-byte value.
The actual cause of CharUpperA's failure is unclear.
The proposed patch takes another route: it converts the character passed by Windows along with WM_MENUCHAR message to UTF-8 and then compares it case-insensitively with the underlined character from a menu item label.
Works for both Russian and English underlined menu entries on Win XP SP2.
Tk 8.4.15 is also affected by this problem since the fix in subject has been backported there.
A minimal testcase:
menu .m
.m add cascade -label \u424\u430\u439\u43B -underline 0
. config -menu .m
Run with 8.4.15 or 8.5a6 then press Alt+any key to trigger a crash.
Proposed bugfix. Unidiff with CRLF format
Logged In: YES
user_id=72656
Originator: NO
dup of fixed 1734223