Bug 454324: Handle error from SelectNode to fix crash when selection-less items are dragged (including, recently, tabs). r+sr=bzbarsky
authorGavin Sharp <gavin.sharp@gmail.com>
Sun, 05 Oct 2008 20:30:09 -0700
changeset 20084 1630d60e624e8119944c5e803993ac67bb7845c3
parent 20083 759221990d1663f6cfd7b2fec40ed1863fde8580
child 20085 7a1870bcfef0069acd15bb199d861d7e539ef351
child 29656 db0fd41f9159fe8d936b3223193a97d1884623ca
push idunknown
push userunknown
push dateunknown
bugs454324
milestone1.9.1b1pre
Bug 454324: Handle error from SelectNode to fix crash when selection-less items are dragged (including, recently, tabs). r+sr=bzbarsky
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -5274,17 +5274,18 @@ PresShell::RenderNode(nsIDOMNode* aNode,
 
   // nothing to draw if the node isn't in a document
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   if (!node->IsInDoc())
     return nsnull;
   
   nsCOMPtr<nsIDOMRange> range;
   NS_NewRange(getter_AddRefs(range));
-  range->SelectNode(aNode);
+  if (NS_FAILED(range->SelectNode(aNode)))
+    return nsnull;
 
   RangePaintInfo* info = CreateRangePaintInfo(range, area);
   if (info && !rangeItems.AppendElement(info)) {
     delete info;
     return nsnull;
   }
 
   if (aRegion) {