diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2024-07-22 12:25:01 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2024-07-22 12:25:01 (GMT) |
commit | 14b416c8a098f473d29296e5af955a1584c41e75 (patch) | |
tree | cb07a2a3240bad909e865d1bad64a1921b6613d4 | |
parent | 5582225db8a3538d65b30d9b30039bc8461a462a (diff) | |
parent | 6e916f429d07206cd992b4696ba371e1f2ae6d4e (diff) | |
download | tk-14b416c8a098f473d29296e5af955a1584c41e75.zip tk-14b416c8a098f473d29296e5af955a1584c41e75.tar.gz tk-14b416c8a098f473d29296e5af955a1584c41e75.tar.bz2 |
Ticket [2d3a81c0] MS-Win: segfault on menubutton destroy: merge fix branch
-rw-r--r-- | generic/tkMenu.c | 10 | ||||
-rw-r--r-- | win/tkWinMenu.c | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c index b32c114..66d919f 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -1012,7 +1012,7 @@ MenuWidgetObjCmd( * * Side effects: * Commands may get excecuted; variables may get set; sub-menus may get - * posted. + * posted, the passed menu may be destroyed. * *---------------------------------------------------------------------- */ @@ -1021,8 +1021,12 @@ int TkInvokeMenu( Tcl_Interp *interp, /* The interp that the menu lives in. */ TkMenu *menuPtr, /* The menu we are invoking. */ - Tcl_Size index) /* The zero based index of the item we are - * invoking. */ + /* Must be protected by Tcl_Preserve + * against freeing by the caller. + * Tk Bug [2d3a81c0]. + */ + Tcl_Size index) /* The zero based index of the item we are + * invoking. */ { int result = TCL_OK; TkMenuEntry *mePtr; diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 29332e2..163566e 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -1238,11 +1238,13 @@ TkWinHandleMenuEvent( interp = menuPtr->interp; Tcl_Preserve(interp); + Tcl_Preserve(menuPtr); code = TkInvokeMenu(interp, menuPtr, mePtr->index); if (code != TCL_OK && code != TCL_CONTINUE && code != TCL_BREAK) { Tcl_AddErrorInfo(interp, "\n (menu invoke)"); Tcl_BackgroundException(interp, code); } + Tcl_Release(menuPtr); Tcl_Release(interp); *plResult = 0; returnResult = 1; |