Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 7d4982e

Browse files
committed
[[ Bug 21924 ]] Fix memory leak when choosing item from macOS popup menu
This patch fixes the failure to release the previously chosen popup menu button label when a new one (from a pick from a macOS popup menu) replaces it. The leak was caused by using MCValueCopy to overwrite the label instance variable, rather than using MCValueAssign to assign to it.
1 parent 009e465 commit 7d4982e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

docs/notes/bugfix-21924.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix memory leak when choosing popup menu item on macOS

engine/src/desktop-menu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ void MCButton::macopenmenu(void)
411411
MCAutoStringRef t_label;
412412
MCPlatformGetMenuItemProperty(m_system_menu, s_popup_menuitem, kMCPlatformMenuItemPropertyTitle, kMCPlatformPropertyTypeMCString, &(&t_label));
413413

414-
/* UNCHECKED */ MCStringCopy(*t_label, label);
414+
MCValueAssign(label, *t_label);
415415
flags |= F_LABEL;
416416

417417
// SN-2014-08-25: [[ Bug 13240 ]] We need to keep the actual popup_menustring,

0 commit comments

Comments
 (0)