Regression(r147639) Causes assertion hit in HashTable
authorch.dumez@sisa.samsung.com <ch.dumez@sisa.samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2013 23:56:13 +0000 (23:56 +0000)
committerch.dumez@sisa.samsung.com <ch.dumez@sisa.samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Apr 2013 23:56:13 +0000 (23:56 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@147681 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/FontCache.cpp

index 32152cd..b1e031b 100644 (file)
@@ -1,3 +1,19 @@
+2013-04-04  Christophe Dumez  <ch.dumez@sisa.samsung.com>
+
+        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  <eric.carlson@apple.com>
 
         [Mac] add "automatic" text track menu item
index 6cf8389..7f00ee4 100644 (file)
@@ -202,22 +202,27 @@ FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fo
                                  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)