Tk Source Code

View Ticket
Login
2007-09-11
04:32 Closed ticket [1734230fff]: Wish crashes while scanning underlined Cyrillic menu entries plus 7 other changes artifact: f6629f37fb user: hobbs
2007-06-10
05:34 Ticket [1734230fff]: 4 changes artifact: fa15e47591 user: flatworm
05:34 Add attachment tkWinMenu.c.diff to ticket [1734230fff] artifact: a59f428554 user: flatworm
2007-06-09
22:34 New ticket [1734230fff] Wish crashes while scanning underlined Cyrillic menu entries. artifact: a67a7fd463 user: flatworm

Ticket UUID: 1734230
Title: Wish crashes while scanning underlined Cyrillic menu entries
Type: Bug Version: obsolete: 8.5a6
Submitter: flatworm Created on: 2007-06-09 22:34:05
Subsystem: 13. Win Menus Assigned To: tmh
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-09-11 04:32:02
Resolution: Duplicate Closed By: hobbs
    Closed on: 2007-09-10 21:32:02
Description:
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.
User Comments: hobbs added on 2007-09-11 04:32:02:
Logged In: YES 
user_id=72656
Originator: NO

dup of fixed 1734223

flatworm added on 2007-06-10 05:34:08:

File Added - 232425: tkWinMenu.c.diff

Attachments: