Changeset 243592 in webkit
- Timestamp:
- Mar 27, 2019, 4:52:44 PM (7 years ago)
- Location:
- branches/safari-607-branch/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
dom/Document.cpp (modified) (1 diff)
-
dom/Document.h (modified) (1 diff)
-
dom/Node.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-607-branch/Source/WebCore/ChangeLog
r243584 r243592 1 2019-03-27 Alan Coon <alancoon@apple.com> 2 3 Cherry-pick r242964. rdar://problem/49359851 4 5 Storing a Node in Ref/RefPtr inside its destructor results in double delete 6 https://bugs.webkit.org/show_bug.cgi?id=195661 7 8 Reviewed by Brent Fulgham. 9 10 Set Node::m_refCount to 1 before calling its virtual destructor. 11 12 This is a security mitigation to prevent any code which ends up storing the node to Ref / RefPtr 13 inside the destructor, which is a programming error caught by debug assertions, from triggering 14 a double-delete on the same Node. 15 16 Such a code would hit the debug assertions in Node::deref() because m_inRemovedLastRefFunction 17 had been set to true by then. 18 19 * dom/Document.cpp: 20 (WebCore::Document::removedLastRef): 21 * dom/Document.h: 22 (WebCore::Document::decrementReferencingNodeCount): 23 * dom/Node.cpp: 24 (WebCore::Node::~Node): 25 (WebCore::Node::removedLastRef): 26 27 28 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242964 268f45cc-cd09-0410-ab3c-d52691b4dbfc 29 30 2019-03-14 Ryosuke Niwa <rniwa@webkit.org> 31 32 Storing a Node in Ref/RefPtr inside its destructor results in double delete 33 https://bugs.webkit.org/show_bug.cgi?id=195661 34 35 Reviewed by Brent Fulgham. 36 37 Set Node::m_refCount to 1 before calling its virtual destructor. 38 39 This is a security mitigation to prevent any code which ends up storing the node to Ref / RefPtr 40 inside the destructor, which is a programming error caught by debug assertions, from triggering 41 a double-delete on the same Node. 42 43 Such a code would hit the debug assertions in Node::deref() because m_inRemovedLastRefFunction 44 had been set to true by then. 45 46 * dom/Document.cpp: 47 (WebCore::Document::removedLastRef): 48 * dom/Document.h: 49 (WebCore::Document::decrementReferencingNodeCount): 50 * dom/Node.cpp: 51 (WebCore::Node::~Node): 52 (WebCore::Node::removedLastRef): 53 1 54 2019-03-27 Alan Coon <alancoon@apple.com> 2 55 -
branches/safari-607-branch/Source/WebCore/dom/Document.cpp
r240377 r243592 722 722 m_deletionHasBegun = true; 723 723 #endif 724 m_refCount = 1; // Avoid double destruction through use of RefPtr<T>. (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.) 724 725 delete this; 725 726 } -
branches/safari-607-branch/Source/WebCore/dom/Document.h
r241508 r243592 383 383 m_deletionHasBegun = true; 384 384 #endif 385 m_refCount = 1; // Avoid double destruction through use of RefPtr<T>. (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.) 385 386 delete this; 386 387 } -
branches/safari-607-branch/Source/WebCore/dom/Node.cpp
r238771 r243592 333 333 { 334 334 ASSERT(isMainThread()); 335 ASSERT(!m_refCount); 335 // We set m_refCount to 1 before calling delete to avoid double destruction through use of Ref<T>/RefPtr<T>. 336 // This is a security mitigation in case of programmer errorm (caught by a debug assertion). 337 ASSERT(m_refCount == 1); 336 338 ASSERT(m_deletionHasBegun); 337 339 ASSERT(!m_adoptionIsRequired); … … 2538 2540 m_deletionHasBegun = true; 2539 2541 #endif 2542 m_refCount = 1; // Avoid double destruction through use of RefPtr<T>. (This is a security mitigation in case of programmer error. It will ASSERT in debug builds.) 2540 2543 delete this; 2541 2544 }
Note:
See TracChangeset
for help on using the changeset viewer.