Fixing bug 594547, crash downstream from nsTreeContentView::InsertRow(). r=bzbarsky@mit.edu, tnikkel@gmail.com, a=LegNeato
authorJohnny Stenback <jst@mozilla.com>
Wed, 17 Nov 2010 14:30:14 -0800
changeset 27215 4fac36e8cd3ee00ad63a4bfdce43a38507590173
parent 27214 815454d74e8ad1af0a9d7a9a2f0637c4b41eea70
child 27216 05202664ed20d295109b92050be5baa9dba6ae80
push id2572
push userjst@mozilla.com
push dateThu, 18 Nov 2010 23:10:36 +0000
reviewersbzbarsky, LegNeato
bugs594547
milestone1.9.1.16pre
Fixing bug 594547, crash downstream from nsTreeContentView::InsertRow(). r=bzbarsky@mit.edu, tnikkel@gmail.com, a=LegNeato
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
@@ -1064,21 +1064,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)