Bug 620394 crash [@ PresShell::GoToAnchor] if selectAnchor && xpointerResult && !sel
authortimeless@mozdev.org
Tue, 21 Dec 2010 15:03:01 -0800
changeset 59581 52b229f6a051f989ad6fced46c44ef1bbfe0b938
parent 59580 438d6a2f3a9ccc09c6c02a2e872d6b72454f5600
child 59582 3e4f01f2a119377f642a0dec4705312187304eeb
push id17673
push userdholbert@mozilla.com
push dateTue, 21 Dec 2010 23:04:38 +0000
treeherdermozilla-central@52b229f6a051 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs620394
milestone2.0b9pre
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 620394 crash [@ PresShell::GoToAnchor] if selectAnchor && xpointerResult && !sel r+a=roc
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -3967,26 +3967,26 @@ PresShell::GoToAnchor(const nsAString& a
         GetSelection(nsISelectionController::SELECTION_NORMAL);
       if (sel) {
         sel->RemoveAllRanges();
         sel->AddRange(jumpToRange);
         if (!selectAnchor) {
           // Use a caret (collapsed selection) at the start of the anchor
           sel->CollapseToStart();
         }
-      }  
-
-      if (selectAnchor && xpointerResult) {
-        // Select the rest (if any) of the ranges in XPointerResult
-        PRUint32 count, i;
-        xpointerResult->GetLength(&count);
-        for (i = 1; i < count; i++) { // jumpToRange is i = 0
-          nsCOMPtr<nsIDOMRange> range;
-          xpointerResult->Item(i, getter_AddRefs(range));
-          sel->AddRange(range);
+
+        if (selectAnchor && xpointerResult) {
+          // Select the rest (if any) of the ranges in XPointerResult
+          PRUint32 count, i;
+          xpointerResult->GetLength(&count);
+          for (i = 1; i < count; i++) { // jumpToRange is i = 0
+            nsCOMPtr<nsIDOMRange> range;
+            xpointerResult->Item(i, getter_AddRefs(range));
+            sel->AddRange(range);
+          }
         }
       }
       // Selection is at anchor.
       // Now focus the document itself if focus is on an element within it.
       nsPIDOMWindow *win = mDocument->GetWindow();
 
       nsIFocusManager* fm = nsFocusManager::GetFocusManager();
       if (fm && win) {