bug 458058 - Crash [@ CallQueryInterface<nsINode, nsIDOMElement>(nsINode*, nsIDOMElement**) ], r=aaronlev
authorMarco Zehe <marco.zehe@googlemail.com>
Thu, 30 Oct 2008 09:24:09 +0100
changeset 21084 4ea96420ec0f0c4eb3c158939968130fa5037705
parent 21083 c5a47d50ea36dc2c73b049d385b1f1424bb08b87
child 21085 a82f43fff223d5cd925626407147d27cbe35683e
push id3296
push usermzehe@mozilla.com
push dateThu, 30 Oct 2008 08:24:43 +0000
treeherdermozilla-central@4ea96420ec0f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaaronlev
bugs458058
milestone1.9.1b2pre
bug 458058 - Crash [@ CallQueryInterface<nsINode, nsIDOMElement>(nsINode*, nsIDOMElement**) ], r=aaronlev
accessible/src/base/nsCoreUtils.cpp
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -162,18 +162,22 @@ already_AddRefed<nsIDOMElement>
 nsCoreUtils::GetDOMElementFor(nsIDOMNode *aNode)
 {
   nsCOMPtr<nsINode> node(do_QueryInterface(aNode));
   nsIDOMElement *element = nsnull;
 
   if (node->IsNodeOfType(nsINode::eELEMENT))
     CallQueryInterface(node, &element);
 
-  else if (node->IsNodeOfType(nsINode::eTEXT))
-    CallQueryInterface(node->GetNodeParent(), &element);
+  else if (node->IsNodeOfType(nsINode::eTEXT)) {
+    nsCOMPtr<nsINode> nodeParent = node->GetNodeParent();
+    NS_ASSERTION(nodeParent, "Text node has no parent!");
+    if (nodeParent)
+      CallQueryInterface(nodeParent, &element);
+  }
 
   else if (node->IsNodeOfType(nsINode::eDOCUMENT)) {
     nsCOMPtr<nsIDOMHTMLDocument> htmlDoc(do_QueryInterface(node));
     if (htmlDoc) {
       nsCOMPtr<nsIDOMHTMLElement> bodyElement;
       htmlDoc->GetBody(getter_AddRefs(bodyElement));
       if (bodyElement) {
         CallQueryInterface(bodyElement, &element);