Fixing bug 594547, crash downstream from nsTreeContentView::InsertRow(). r=bzbarsky@mit.edu, tnikkel@gmail.com, a=jst@mozilla.org
authorJohnny Stenback <jst@mozilla.com>
Wed, 17 Nov 2010 14:30:14 -0800
changeset 57870 99a5d8039d3e8134afc04d00ed70dc34fc3e333c
parent 57869 1709bbd7964fbba801c94518b3bdea44adcc2fcd
child 57871 30484d51bb7b34ec14e98bfb442b438a91944d6c
push id17052
push userjst@mozilla.com
push dateThu, 18 Nov 2010 21:56:48 +0000
treeherdermozilla-central@99a5d8039d3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky, jst
bugs594547
milestone2.0b8pre
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
Fixing bug 594547, crash downstream from nsTreeContentView::InsertRow(). r=bzbarsky@mit.edu, tnikkel@gmail.com, a=jst@mozilla.org
layout/xul/base/src/tree/src/nsTreeContentView.cpp
--- a/layout/xul/base/src/tree/src/nsTreeContentView.cpp
+++ b/layout/xul/base/src/tree/src/nsTreeContentView.cpp
@@ -1086,21 +1086,24 @@ nsTreeContentView::ContentInserted(nsIDo
         mBoxObject->InvalidateRow(index);
     }
   }
   else if (childTag == nsGkAtoms::optgroup) {
     InsertRowFor(aContainer, aChild);
   }
   else if (childTag == nsGkAtoms::option) {
     PRInt32 parentIndex = FindContent(aContainer);
-    PRInt32 index = 0;
-    GetIndexInSubtree(aContainer, aChild, &index);
-    PRInt32 count = InsertRow(parentIndex, index, aChild);
-    if (mBoxObject)
-      mBoxObject->RowCountChanged(parentIndex + index + 1, count);
+
+    if (parentIndex >= 0) {
+      PRInt32 index = 0;
+      GetIndexInSubtree(aContainer, aChild, &index);
+      PRInt32 count = InsertRow(parentIndex, index, aChild);
+      if (mBoxObject)
+        mBoxObject->RowCountChanged(parentIndex + index + 1, count);
+    }
   }
 }
 
 void
 nsTreeContentView::ContentRemoved(nsIDocument *aDocument,
                                   nsIContent* aContainer,
                                   nsIContent* aChild,
                                   PRInt32 aIndexInContainer,