Changeset 242964 in webkit
- Timestamp:
- Mar 14, 2019, 2:09:46 PM (7 years ago)
- Location:
- trunk/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
-
trunk/Source/WebCore/ChangeLog
r242963 r242964 1 2019-03-14 Ryosuke Niwa <rniwa@webkit.org> 2 3 Storing a Node in Ref/RefPtr inside its destructor results in double delete 4 https://bugs.webkit.org/show_bug.cgi?id=195661 5 6 Reviewed by Brent Fulgham. 7 8 Set Node::m_refCount to 1 before calling its virtual destructor. 9 10 This is a security mitigation to prevent any code which ends up storing the node to Ref / RefPtr 11 inside the destructor, which is a programming error caught by debug assertions, from triggering 12 a double-delete on the same Node. 13 14 Such a code would hit the debug assertions in Node::deref() because m_inRemovedLastRefFunction 15 had been set to true by then. 16 17 * dom/Document.cpp: 18 (WebCore::Document::removedLastRef): 19 * dom/Document.h: 20 (WebCore::Document::decrementReferencingNodeCount): 21 * dom/Node.cpp: 22 (WebCore::Node::~Node): 23 (WebCore::Node::removedLastRef): 24 1 25 2019-03-14 Brent Fulgham <bfulgham@apple.com> 2 26 -
trunk/Source/WebCore/dom/Document.cpp
r242899 r242964 721 721 m_deletionHasBegun = true; 722 722 #endif 723 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.) 723 724 delete this; 724 725 } -
trunk/Source/WebCore/dom/Document.h
r242759 r242964 377 377 m_deletionHasBegun = true; 378 378 #endif 379 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.) 379 380 delete this; 380 381 } -
trunk/Source/WebCore/dom/Node.cpp
r241932 r242964 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); … … 2533 2535 m_deletionHasBegun = true; 2534 2536 #endif 2537 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.) 2535 2538 delete this; 2536 2539 }
Note:
See TracChangeset
for help on using the changeset viewer.