summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2024-07-22 12:16:02 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2024-07-22 12:16:02 (GMT)
commit6e916f429d07206cd992b4696ba371e1f2ae6d4e (patch)
treef597de8944d816907309c380fabc48fa30723a8f
parent0b6bf2703a09587c1ed87b5350c04210fa8edcea (diff)
parentf18f82b3a73261b2d71dc4ee5c7c19ec87546fc1 (diff)
downloadtk-6e916f429d07206cd992b4696ba371e1f2ae6d4e.zip
tk-6e916f429d07206cd992b4696ba371e1f2ae6d4e.tar.gz
tk-6e916f429d07206cd992b4696ba371e1f2ae6d4e.tar.bz2
Ticket [2d3a81c0] MS-Win: segfault on menubutton destroy: merge fix branch
-rw-r--r--generic/tkMenu.c6
-rw-r--r--win/tkWinMenu.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index 715c6d7..fcf49a6 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -982,7 +982,7 @@ MenuWidgetObjCmd(
*
* Side effects:
* Commands may get excecuted; variables may get set; sub-menus may get
- * posted.
+ * posted, the passed menu may be destroyed.
*
*----------------------------------------------------------------------
*/
@@ -991,6 +991,10 @@ int
TkInvokeMenu(
Tcl_Interp *interp, /* The interp that the menu lives in. */
TkMenu *menuPtr, /* The menu we are invoking. */
+ /* Must be protected by Tcl_Preserve
+ * against freeing by the caller.
+ * Tk Bug [2d3a81c0].
+ */
int index) /* The zero based index of the item we are
* invoking. */
{
diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c
index a07765a..cd7c4aa 100644
--- a/win/tkWinMenu.c
+++ b/win/tkWinMenu.c
@@ -1240,11 +1240,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;