Bug 1178984 - Crashes at nsMenuBarX::RemoveMenuAtIndex. r=spohl
authorSteven Michaud <smichaud@pobox.com>
Wed, 01 Jul 2015 14:28:05 -0500
changeset 251015 39a2abd5d26c8f0a1537d0a190b79d616362bd72
parent 251014 cc68ce01105fb2d8b54e3b05b2a8a4b0d1deb2f7
child 251016 a2c6a5972acba96ba70549261d44c102982c49e7
push id28980
push usercbook@mozilla.com
push dateThu, 02 Jul 2015 13:44:32 +0000
treeherdermozilla-central@f1b3144fed94 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl
bugs1178984
milestone42.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1178984 - Crashes at nsMenuBarX::RemoveMenuAtIndex. r=spohl
widget/cocoa/nsMenuBarX.mm
--- a/widget/cocoa/nsMenuBarX.mm
+++ b/widget/cocoa/nsMenuBarX.mm
@@ -236,17 +236,20 @@ nsresult nsMenuBarX::InsertMenuAtIndex(n
 
   NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
 }
 
 void nsMenuBarX::RemoveMenuAtIndex(uint32_t aIndex)
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
-  NS_ASSERTION(aIndex < mMenuArray.Length(), "Attempting submenu removal with bad index!");
+  if (mMenuArray.Length() <= aIndex) {
+    NS_ERROR("Attempting submenu removal with bad index!");
+    return;
+  }
 
   // Our native menu and our internal menu object array might be out of sync.
   // This happens, for example, when a submenu is hidden. Because of this we
   // should not assume that a native submenu is hooked up.
   NSMenuItem* nativeMenuItem = mMenuArray[aIndex]->NativeMenuItem();
   int nativeMenuItemIndex = [mNativeMenu indexOfItem:nativeMenuItem];
   if (nativeMenuItemIndex != -1)
     [mNativeMenu removeItemAtIndex:nativeMenuItemIndex];