Bug 1185589 - Fix unintentional assignment in PuppetWidget::ExecuteNativeKeyBinding. r=masayuki, a=2.0+
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Wed, 22 Jul 2015 14:52:32 -0400
changeset 204943 90e98e683875
parent 204942 7db5c7bd2976
child 204944 ff36938d2716
push id864
push userryanvm@gmail.com
push dateThu, 23 Jul 2015 02:09:24 +0000
treeherdermozilla-b2g32_v2_0@ff36938d2716 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki, 2
bugs1185589
milestone32.0
Bug 1185589 - Fix unintentional assignment in PuppetWidget::ExecuteNativeKeyBinding. r=masayuki, a=2.0+
widget/xpwidgets/PuppetWidget.cpp
--- a/widget/xpwidgets/PuppetWidget.cpp
+++ b/widget/xpwidgets/PuppetWidget.cpp
@@ -329,35 +329,38 @@ PuppetWidget::ExecuteNativeKeyBinding(Na
                                       void* aCallbackData)
 {
   // B2G doesn't have native key bindings.
 #ifdef MOZ_B2G
   return false;
 #else // #ifdef MOZ_B2G
   MOZ_ASSERT(mNativeKeyCommandsValid);
 
-  nsTArray<mozilla::CommandInt>& commands = mSingleLineCommands;
+  const nsTArray<mozilla::CommandInt>* commands = nullptr;
   switch (aType) {
     case nsIWidget::NativeKeyBindingsForSingleLineEditor:
-      commands = mSingleLineCommands;
+      commands = &mSingleLineCommands;
       break;
     case nsIWidget::NativeKeyBindingsForMultiLineEditor:
-      commands = mMultiLineCommands;
+      commands = &mMultiLineCommands;
       break;
     case nsIWidget::NativeKeyBindingsForRichTextEditor:
-      commands = mRichTextCommands;
+      commands = &mRichTextCommands;
+      break;
+    default:
+      MOZ_CRASH("Invalid type");
       break;
   }
 
-  if (commands.IsEmpty()) {
+  if (commands->IsEmpty()) {
     return false;
   }
 
-  for (uint32_t i = 0; i < commands.Length(); i++) {
-    aCallback(static_cast<mozilla::Command>(commands[i]), aCallbackData);
+  for (uint32_t i = 0; i < commands->Length(); i++) {
+    aCallback(static_cast<mozilla::Command>((*commands)[i]), aCallbackData);
   }
   return true;
 #endif
 }
 
 LayerManager*
 PuppetWidget::GetLayerManager(PLayerTransactionChild* aShadowManager,
                               LayersBackend aBackendHint,