summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authoroehhar <harald.oehlmann@elmicron.de>2024-07-18 07:48:06 (GMT)
committeroehhar <harald.oehlmann@elmicron.de>2024-07-18 07:48:06 (GMT)
commit0179267bd9b6697599c3999abd30d668feee35ed (patch)
treef0c6ec81c48440574ed1021f57ae618c093e9dca /generic
parent405cd1740e12c6b84187670afbaf7f835310c288 (diff)
downloadtk-0179267bd9b6697599c3999abd30d668feee35ed.zip
tk-0179267bd9b6697599c3999abd30d668feee35ed.tar.gz
tk-0179267bd9b6697599c3999abd30d668feee35ed.tar.bz2
Ticket [2d3a81c0] menubutton destroy segfault: proposed solution to preserve also the menu
Diffstat (limited to 'generic')
-rw-r--r--generic/tkMenu.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index 715c6d7..15c8031 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -1005,6 +1005,11 @@ TkInvokeMenu(
goto done;
}
+ /*
+ * Tk Bug 2d3a81c0: menu may be freed in callback, but menu item is
+ * preserved. As menu is required to delete menu item later, it segfaults.
+ */
+ Tcl_Preserve(menuPtr);
Tcl_Preserve(mePtr);
if (mePtr->type == TEAROFF_ENTRY) {
Tcl_DString ds;
@@ -1062,6 +1067,7 @@ TkInvokeMenu(
Tcl_DecrRefCount(commandPtr);
}
Tcl_Release(mePtr);
+ Tcl_Release(menuPtr);
done:
return result;