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

Side by Side 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: Removes unneeded ref to node |n|. 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « LayoutTests/editing/selection/contains-node-crash-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const 447 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const
448 { 448 {
449 if (!m_frame) 449 if (!m_frame)
450 return false; 450 return false;
451 451
452 FrameSelection* selection = m_frame->selection(); 452 FrameSelection* selection = m_frame->selection();
453 453
454 if (!n || m_frame->document() != n->document() || selection->isNone()) 454 if (!n || m_frame->document() != n->document() || selection->isNone())
455 return false; 455 return false;
456 456
457 ContainerNode* parentNode = n->parentNode();
458 unsigned nodeIndex = n->nodeIndex(); 457 unsigned nodeIndex = n->nodeIndex();
459 RefPtr<Range> selectedRange = selection->selection().toNormalizedRange(); 458 RefPtr<Range> selectedRange = selection->selection().toNormalizedRange();
460 459
460 ContainerNode* parentNode = n->parentNode();
461 if (!parentNode) 461 if (!parentNode)
462 return false; 462 return false;
463 463
464 ExceptionCode ec = 0; 464 ExceptionCode ec = 0;
465 bool nodeFullySelected = Range::compareBoundaryPoints(parentNode, nodeIndex, selectedRange->startContainer(), selectedRange->startOffset(), ec) >= 0 && !ec 465 bool nodeFullySelected = Range::compareBoundaryPoints(parentNode, nodeIndex, selectedRange->startContainer(), selectedRange->startOffset(), ec) >= 0 && !ec
466 && Range::compareBoundaryPoints(parentNode, nodeIndex + 1, selectedRange ->endContainer(), selectedRange->endOffset(), ec) <= 0 && !ec; 466 && Range::compareBoundaryPoints(parentNode, nodeIndex + 1, selectedRange ->endContainer(), selectedRange->endOffset(), ec) <= 0 && !ec;
467 ASSERT(!ec); 467 ASSERT(!ec);
468 if (nodeFullySelected) 468 if (nodeFullySelected)
469 return true; 469 return true;
470 470
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 530
531 bool DOMSelection::isValidForPosition(Node* node) const 531 bool DOMSelection::isValidForPosition(Node* node) const
532 { 532 {
533 ASSERT(m_frame); 533 ASSERT(m_frame);
534 if (!node) 534 if (!node)
535 return true; 535 return true;
536 return node->document() == m_frame->document(); 536 return node->document() == m_frame->document();
537 } 537 }
538 538
539 } // namespace WebCore 539 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/editing/selection/contains-node-crash-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698