[haiku-commits] Change in haiku[master]: BMenu: fix memory leak in scripting

  • From: Gerrit <review@xxxxxxxxxxxxxxxxxxx>
  • To: waddlesplash <waddlesplash@xxxxxxxxx>, haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 2 Jul 2020 14:53:46 +0000

From X512 <danger_mail@xxxxxxx>:

X512 has uploaded this change for review. ( 
https://review.haiku-os.org/c/haiku/+/2978 ;)


Change subject: BMenu: fix memory leak in scripting
......................................................................

BMenu: fix memory leak in scripting

Change-Id: Ia283594a622f758189cc8280683a4e068ae1f3af
---
M src/kits/interface/Menu.cpp
1 file changed, 6 insertions(+), 2 deletions(-)



  git pull ssh://git.haiku-os.org:22/haiku refs/changes/78/2978/1

diff --git a/src/kits/interface/Menu.cpp b/src/kits/interface/Menu.cpp
index f280436..f00920d 100644
--- a/src/kits/interface/Menu.cpp
+++ b/src/kits/interface/Menu.cpp
@@ -1670,8 +1670,10 @@
                                if (err >= B_OK) {
                                        if (item->Submenu() == NULL)
                                                err = B_BAD_VALUE;
-                                       else
+                                       else {
                                                RemoveItem(item);
+                                               delete item;
+                                       }
                                }
                        }
                        break;
@@ -1737,8 +1739,10 @@
                        if (message->what == B_DELETE_PROPERTY) {
                                BMenuItem *item = NULL;
                                err = _ResolveItemSpecifier(specifier, what, 
item);
-                               if (err >= B_OK)
+                               if (err >= B_OK) {
                                        RemoveItem(item);
+                                       delete item;
+                               }
                        }
                        break;
                case 12: { // MenuItem: EXECUTE

--
To view, visit https://review.haiku-os.org/c/haiku/+/2978
To unsubscribe, or for help writing mail filters, visit 
https://review.haiku-os.org/settings

Gerrit-Project: haiku
Gerrit-Branch: master
Gerrit-Change-Id: Ia283594a622f758189cc8280683a4e068ae1f3af
Gerrit-Change-Number: 2978
Gerrit-PatchSet: 1
Gerrit-Owner: X512 <danger_mail@xxxxxxx>
Gerrit-MessageType: newchange

Other related posts: