Bug 1178984 - Crashes at nsMenuBarX::RemoveMenuAtIndex. r=spohl, a=lmandel
authorSteven Michaud <smichaud@pobox.com>
Wed, 01 Jul 2015 14:28:05 -0500
changeset 275265 c75740b01281fa97ba9186affccd755c6571ac47
parent 275264 f57eba518474fc1ae1de2e18059fd2b1c9874657
child 275266 7f27d50242f695dac61626670650d25ccaab5b34
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersspohl, lmandel
bugs1178984
milestone40.0
Bug 1178984 - Crashes at nsMenuBarX::RemoveMenuAtIndex. r=spohl, a=lmandel
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];