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

Unified Diff: Source/core/page/DOMSelection.cpp

Issue 15390003: Use-after-free in WebCore::Range::compareBoundaryPoints (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 7 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 | « Source/core/page/DOMSelection.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/page/DOMSelection.cpp
diff --git a/Source/core/page/DOMSelection.cpp b/Source/core/page/DOMSelection.cpp
index ed91368b54e33510b8c38708c047c5e0a8308bde..bd0dad831a7364680147adc7dabb7871a0a6e119 100644
--- a/Source/core/page/DOMSelection.cpp
+++ b/Source/core/page/DOMSelection.cpp
@@ -444,20 +444,24 @@ void DOMSelection::deleteFromDocument()
setBaseAndExtent(selectedRange->startContainer(ASSERT_NO_EXCEPTION), selectedRange->startOffset(), selectedRange->startContainer(), selectedRange->startOffset(), ASSERT_NO_EXCEPTION);
}
-bool DOMSelection::containsNode(const Node* n, bool allowPartial) const
+bool DOMSelection::containsNode(Node* n, bool allowPartial) const
{
if (!m_frame)
return false;
+ // toNormalizedRange can trigger layout, which can remove the last
+ // reference to node |n|,
ojan 2013/05/20 02:30:48 The render tree doesn't hold refptrs to Nodes AFAI
+ RefPtr<Node> protect(n);
+
FrameSelection* selection = m_frame->selection();
if (!n || m_frame->document() != n->document() || selection->isNone())
return false;
- ContainerNode* parentNode = n->parentNode();
unsigned nodeIndex = n->nodeIndex();
RefPtr<Range> selectedRange = selection->selection().toNormalizedRange();
+ ContainerNode* parentNode = n->parentNode();
if (!parentNode)
return false;
« no previous file with comments | « Source/core/page/DOMSelection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698