LayoutBuilder.h: Fix use after free
Fix 'item' is used after delete. Pointed out by Clang Static Analyzer. Change-Id: I8eca3084c97b37015a2da1b96119a458d4eb9aa7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/3392 Reviewed-by: Adrien Destugues <pulkomandy@gmail.com> Reviewed-by: John Scipione <jscipione@gmail.com>
This commit is contained in:
parent
a6c8647e0a
commit
cb5156f081
@ -1737,8 +1737,10 @@ Menu<ParentBuilder>::AddItem(const char* label, BMessage* message,
|
||||
char shortcut, uint32 modifiers)
|
||||
{
|
||||
BMenuItem* item = new BMenuItem(label, message, shortcut, modifiers);
|
||||
if (!fMenu->AddItem(item))
|
||||
if (!fMenu->AddItem(item)) {
|
||||
delete item;
|
||||
item = NULL;
|
||||
}
|
||||
|
||||
return MenuItem<ParentBuilder>(this->fParent, fMenu, item);
|
||||
}
|
||||
@ -1758,8 +1760,10 @@ Menu<ParentBuilder>::AddItem(const char* label, uint32 messageWhat,
|
||||
throw;
|
||||
}
|
||||
|
||||
if (!fMenu->AddItem(item))
|
||||
if (!fMenu->AddItem(item)) {
|
||||
delete item;
|
||||
item = NULL;
|
||||
}
|
||||
|
||||
return MenuItem<ParentBuilder>(this->fParent, fMenu, item);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user