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

Unified Diff: Source/core/rendering/FastTextAutosizer.cpp

Issue 274463002: Speculative fix for crash accessing a supercluster root. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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/rendering/FastTextAutosizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/FastTextAutosizer.cpp
diff --git a/Source/core/rendering/FastTextAutosizer.cpp b/Source/core/rendering/FastTextAutosizer.cpp
index 2dea427fd5d3e084551eb6a921d051a28f0eab79..4c3e2738906531d38b1cf5358a97d2c82d75669a 100644
--- a/Source/core/rendering/FastTextAutosizer.cpp
+++ b/Source/core/rendering/FastTextAutosizer.cpp
@@ -320,9 +320,17 @@ void FastTextAutosizer::destroy(const RenderBlock* block)
{
if (!m_pageInfo.m_settingEnabled)
return;
+
ASSERT(!m_blocksThatHaveBegunLayout.contains(block));
- m_fingerprintMapper.remove(block);
+ if (m_fingerprintMapper.remove(block) && m_firstBlockToBeginLayout) {
+ // RenderBlock with a fingerprint was destroyed during layout.
+ // Clear the cluster stack and the supercluster map to avoid stale pointers.
+ // Speculative fix for http://crbug.com/369485.
+ m_firstBlockToBeginLayout = 0;
+ m_clusterStack.clear();
+ m_superclusters.clear();
+ }
}
FastTextAutosizer::BeginLayoutBehavior FastTextAutosizer::prepareForLayout(const RenderBlock* block)
@@ -1058,15 +1066,15 @@ void FastTextAutosizer::FingerprintMapper::addTentativeClusterRoot(const RenderB
#endif
}
-void FastTextAutosizer::FingerprintMapper::remove(const RenderObject* renderer)
+bool FastTextAutosizer::FingerprintMapper::remove(const RenderObject* renderer)
{
Fingerprint fingerprint = m_fingerprints.take(renderer);
if (!fingerprint || !renderer->isRenderBlock())
- return;
+ return false;
ReverseFingerprintMap::iterator blocksIter = m_blocksForFingerprint.find(fingerprint);
if (blocksIter == m_blocksForFingerprint.end())
- return;
+ return false;
BlockSet& blocks = *blocksIter->value;
blocks.remove(toRenderBlock(renderer));
@@ -1075,6 +1083,7 @@ void FastTextAutosizer::FingerprintMapper::remove(const RenderObject* renderer)
#ifndef NDEBUG
assertMapsAreConsistent();
#endif
+ return true;
}
FastTextAutosizer::Fingerprint FastTextAutosizer::FingerprintMapper::get(const RenderObject* renderer)
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698