Title: [147681] trunk/Source/WebCore
Revision
147681
Author
[email protected]
Date
2013-04-04 16:56:13 -0700 (Thu, 04 Apr 2013)

Log Message

Regression(r147639) Causes assertion hit in HashTable
https://bugs.webkit.org/show_bug.cgi?id=113954

Reviewed by Benjamin Poulain.

Lookup the key in the hash table again after the recursive call to
getCachedFontPlatformData() as it may have altered the hash map and
invalidated the previous iterator we had.

No new tests, covered by existing tests.

* platform/graphics/FontCache.cpp:
(WebCore::FontCache::getCachedFontPlatformData):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (147680 => 147681)


--- trunk/Source/WebCore/ChangeLog	2013-04-04 23:52:54 UTC (rev 147680)
+++ trunk/Source/WebCore/ChangeLog	2013-04-04 23:56:13 UTC (rev 147681)
@@ -1,3 +1,19 @@
+2013-04-04  Christophe Dumez  <[email protected]>
+
+        Regression(r147639) Causes assertion hit in HashTable
+        https://bugs.webkit.org/show_bug.cgi?id=113954
+
+        Reviewed by Benjamin Poulain.
+
+        Lookup the key in the hash table again after the recursive call to
+        getCachedFontPlatformData() as it may have altered the hash map and
+        invalidated the previous iterator we had.
+
+        No new tests, covered by existing tests.
+
+        * platform/graphics/FontCache.cpp:
+        (WebCore::FontCache::getCachedFontPlatformData):
+
 2013-04-04  Eric Carlson  <[email protected]>
 
         [Mac] add "automatic" text track menu item

Modified: trunk/Source/WebCore/platform/graphics/FontCache.cpp (147680 => 147681)


--- trunk/Source/WebCore/platform/graphics/FontCache.cpp	2013-04-04 23:52:54 UTC (rev 147680)
+++ trunk/Source/WebCore/platform/graphics/FontCache.cpp	2013-04-04 23:56:13 UTC (rev 147681)
@@ -202,22 +202,27 @@
                                  fontDescription.widthVariant());
 
     FontPlatformDataCache::AddResult result = gFontPlatformDataCache->add(key, nullptr);
+    FontPlatformDataCache::iterator it = result.iterator;
     if (result.isNewEntry) {
-        result.iterator->value = createFontPlatformData(fontDescription, familyName);
+        it->value = createFontPlatformData(fontDescription, familyName);
 
-        if (!result.iterator->value && !checkingAlternateName) {
+        if (!it->value && !checkingAlternateName) {
             // We were unable to find a font.  We have a small set of fonts that we alias to other names,
             // e.g., Arial/Helvetica, Courier/Courier New, etc.  Try looking up the font under the aliased name.
             const AtomicString& alternateName = alternateFamilyName(familyName);
             if (!alternateName.isEmpty()) {
                 FontPlatformData* fontPlatformDataForAlternateName = getCachedFontPlatformData(fontDescription, alternateName, true);
+                // Lookup the key in the hash table again as the previous iterator may have
+                // been invalidated by the recursive call to getCachedFontPlatformData().
+                it = gFontPlatformDataCache->find(key);
+                ASSERT(it != gFontPlatformDataCache->end());
                 if (fontPlatformDataForAlternateName)
-                    result.iterator->value = adoptPtr(new FontPlatformData(*fontPlatformDataForAlternateName));
+                    it->value = adoptPtr(new FontPlatformData(*fontPlatformDataForAlternateName));
             }
         }
     }
 
-    return result.iterator->value.get();
+    return it->value.get();
 }
 
 #if ENABLE(OPENTYPE_VERTICAL)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to