Tk Source Code

View Ticket
Login
Ticket UUID: 499c0467b3f3bdcf55afede2e8eedc110fc9de47
Title: DestroyMenuInstance(): use Tcl_EventuallyFree() rather than directly calling DestroyMenuEntry()
Type: Patch Version: core-8-6-branch
Submitter: chrstphrchvz Created on: 2022-10-08 13:14:29
Subsystem: 10. Generic Menus Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2023-07-23 12:20:26
Resolution: Fixed Closed By: fvogel
    Closed on: 2023-07-23 12:20:26
Description:

At least since the beginning of the check-in history, DestroyMenuInstance() has called DestroyMenuEntry() directly rather than through Tcl_EventuallyFree(). This is inconsistent, and it seems incidental for this to not be causing any use-after-free issues in anything currently doing Tcl_Preserve(mePtr)/Tcl_Release(mePtr). Unless there is a good reason for not using Tcl_EventuallyFree() in DestroyMenuInstance() which I am not aware of, I believe this should be adjusted. See attached patch.

User Comments: fvogel added on 2023-07-23 12:20:26:
OK, done. This fix is now merged in core-8-6-branch and trunk.

chrstphrchvz added on 2023-07-20 02:33:11:

This patch is for generic code. It is unrelated to [09a11fb1228f] aside from causing any “freed by…” call stack to contain:

⋮
DestroyMenuEntry
Tcl_EventuallyFree
DestroyMenuInstance
⋮
instead of:
⋮
DestroyMenuEntry
DestroyMenuInstance
⋮

If desirable, this patch can be committed separately and then backed out of the bug-09a11fb1228f branch.


fvogel added on 2023-07-19 21:50:05:

Marc, can these changes be merged please?


fvogel added on 2022-10-09 16:10:21:
Experimented in [d11d59e8] by Marc Culler.

Attachments: