Commit d6517365 authored by abarth@webkit.org's avatar abarth@webkit.org

WebCore:

2008-06-24  Anonymous

        Reviewed by Darin Adler.  Committed by Adam Barth.

        https://bugs.webkit.org/show_bug.cgi?id=19470

        Check for a null documentElement() to fix four crashes.

        * WebCore/dom/Document.cpp:
        * WebCore/dom/Node.cpp:

LayoutTests:

2008-06-24  Anonymous

        Reviewed by Darin Adler.  Committed by Adam Barth.

        https://bugs.webkit.org/show_bug.cgi?id=19470

        Check for a null documentElement() to fix four crashes.

        * LayoutTests/fast/dom/documentElement-null-expected.txt: Added.
        * LayoutTests/fast/dom/documentElement-null.html: Added.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34789 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent aea2f4fc
2008-06-24 Anonymous
Reviewed by Darin Adler. Committed by Adam Barth.
https://bugs.webkit.org/show_bug.cgi?id=19470
Check for a null documentElement() to fix four crashes.
* LayoutTests/fast/dom/documentElement-null-expected.txt: Added.
* LayoutTests/fast/dom/documentElement-null.html: Added.
2008-06-24 Adam Barth <abarth@webkit.org>
Reviewed by Darin Adler.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<title>Weee!</title>
<script>
window.onload = function() {
if (window.layoutTestController)
window.layoutTestController.dumpAsText();
var meths = [
document.lookupNamespaceURI,
document.isDefaultNamespace,
function(node) { this.body = node },
document.lookupPrefix
];
var node = document.createElement('b');
// Empty the document
while (document.firstChild)
document.removeChild(document.firstChild);
for (var i = 0, il = meths.length; i < il; ++i) {
try {
// Some expect nodes, some expect strings, but our nodes will get
// toString'd so we should be ok on both.
meths[i].call(document, node, node, node);
} catch(e) { }
}
document.open();
document.write('PASS');
document.close();
};
</script>
</head>
<body>
<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=19470">bug 19470</a>:
Null pointer dereferences on a document with no documentElement.</p>
<p>On success, should print PASS.</p>
</body>
</html>
2008-06-24 Anonymous
Reviewed by Darin Adler. Committed by Adam Barth.
https://bugs.webkit.org/show_bug.cgi?id=19470
Check for a null documentElement() to fix four crashes.
* WebCore/dom/Document.cpp:
* WebCore/dom/Node.cpp:
2008-06-24 Adam Barth <abarth@webkit.org>
Reviewed by Darin Adler.
......@@ -1453,7 +1453,7 @@ HTMLElement* Document::body()
void Document::setBody(PassRefPtr<HTMLElement> newBody, ExceptionCode& ec)
{
if (!newBody) {
if (!newBody || !documentElement()) {
ec = HIERARCHY_REQUEST_ERR;
return;
}
......
......@@ -1383,7 +1383,9 @@ bool Node::isDefaultNamespace(const String &namespaceURI) const
return false;
}
case DOCUMENT_NODE:
return static_cast <const Document *>(this)->documentElement()->isDefaultNamespace(namespaceURI);
if (Element* de = static_cast<const Document*>(this)->documentElement())
return de->isDefaultNamespace(namespaceURI);
return false;
case ENTITY_NODE:
case NOTATION_NODE:
case DOCUMENT_TYPE_NODE:
......@@ -1414,7 +1416,9 @@ String Node::lookupPrefix(const String &namespaceURI) const
case ELEMENT_NODE:
return lookupNamespacePrefix(namespaceURI, static_cast<const Element *>(this));
case DOCUMENT_NODE:
return static_cast<const Document *>(this)->documentElement()->lookupPrefix(namespaceURI);
if (Element* de = static_cast<const Document*>(this)->documentElement())
return de->lookupPrefix(namespaceURI);
return String();
case ENTITY_NODE:
case NOTATION_NODE:
case DOCUMENT_FRAGMENT_NODE:
......@@ -1472,7 +1476,9 @@ String Node::lookupNamespaceURI(const String &prefix) const
return String();
}
case DOCUMENT_NODE:
return static_cast<const Document *>(this)->documentElement()->lookupNamespaceURI(prefix);
if (Element* de = static_cast<const Document*>(this)->documentElement())
return de->lookupNamespaceURI(prefix);
return String();
case ENTITY_NODE:
case NOTATION_NODE:
case DOCUMENT_TYPE_NODE:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment