Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(443)

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2752673003: DOM: adoptNode() should not crash by reparenting the specified node in removeChild(). (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/dom/document/adoptNode-reparenting-crash.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index e184fe385333a69833f7ddf0a12bd685793567e7..07e97ae3d3e79475e1d08691a3a2f559e0d92cb5 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -1182,7 +1182,16 @@ Node* Document::adoptNode(Node* source, ExceptionState& exceptionState) {
source->parentNode()->removeChild(source, exceptionState);
if (exceptionState.hadException())
return nullptr;
- CHECK(!source->parentNode());
+ // The above removeChild() can execute arbitrary JavaScript code.
+ if (source->parentNode()) {
+ addConsoleMessage(ConsoleMessage::create(
+ JSMessageSource, WarningMessageLevel,
+ ExceptionMessages::failedToExecute("adoptNode", "Document",
+ "Unable to remove the "
+ "specified node from the "
+ "original parent.")));
+ return nullptr;
+ }
}
}
« no previous file with comments | « third_party/WebKit/LayoutTests/dom/document/adoptNode-reparenting-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698