From 264c172a1f12285216bcc20fe2fbd7eec2582a1a Mon Sep 17 00:00:00 2001 From: chengyemao Date: Tue, 18 Jan 2005 15:24:18 +0000 Subject: Fixed a bug by adding code the check menu index in selection. This bug caused an access violation in an embedded menu testing when the mouse clicked the last pull-down menu entry --- win/tkWinMenu.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index ef881e0..766e3c3 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkWinMenu.c,v 1.42 2005/01/17 07:00:11 chengyemao Exp $ + * RCS: @(#) $Id: tkWinMenu.c,v 1.43 2005/01/18 15:24:18 chengyemao Exp $ */ #define OEMRESOURCE @@ -1237,14 +1237,15 @@ TkWinHandleMenuEvent(phwnd, pMessage, pwParam, plParam, plResult) } if (menuPtr != NULL) { + long entryIndex = LOWORD(*pwParam); mePtr = NULL; - if (flags != 0xFFFF) { + if (flags != 0xFFFF && entryIndex < menuPtr->numEntries) { if (flags & MF_POPUP) { - mePtr = menuPtr->entries[LOWORD(*pwParam)]; + mePtr = menuPtr->entries[entryIndex]; } else { hashEntryPtr = Tcl_FindHashEntry( &tsdPtr->commandTable, - (char *) LOWORD(*pwParam)); + (char *) entryIndex); if (hashEntryPtr != NULL) { mePtr = (TkMenuEntry *) Tcl_GetHashValue(hashEntryPtr); -- cgit v0.12