In FontCacheAndroid.cpp should keep the pointer valid returned from CString::data()
authorwangxianzhu@chromium.org <wangxianzhu@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2011 19:21:45 +0000 (19:21 +0000)
committerwangxianzhu@chromium.org <wangxianzhu@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2011 19:21:45 +0000 (19:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=73849

The changed code has been covered by many existing layout tests.

Reviewed by Adam Barth.

* platform/graphics/chromium/FontCacheAndroid.cpp:
(WebCore::FontCache::createFontPlatformData):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/chromium/FontCacheAndroid.cpp

index d673ef4..0a5a436 100644 (file)
@@ -1,3 +1,15 @@
+2011-12-07  Xianzhu Wang  <wangxianzhu@chromium.org>
+
+        In FontCacheAndroid.cpp should keep the pointer valid returned from CString::data()
+        https://bugs.webkit.org/show_bug.cgi?id=73849
+
+        The changed code has been covered by many existing layout tests.
+
+        Reviewed by Adam Barth.
+
+        * platform/graphics/chromium/FontCacheAndroid.cpp:
+        (WebCore::FontCache::createFontPlatformData):
+
 2011-12-07  Xiaomei Ji  <xji@chromium.org>
 
         Turn on move caret by word visually for Windows platform.
index 82589bb..4acb5ff 100644 (file)
@@ -147,13 +147,16 @@ void FontCache::getTraitsInFamily(const AtomicString& familyName, Vector<unsigne
 FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
 {
     const char* name = 0;
+    CString nameString; // Keeps name valid within scope of this function in case that name is from a family.
 
     // If a fallback font is being created (e.g. "-webkit-monospace"), convert
     // it in to the fallback name (e.g. "monospace").
     if (!family.length() || family.startsWith("-webkit-"))
         name = getFallbackFontName(fontDescription);
-    else
-        name = family.string().utf8().data();
+    else {
+        nameString = family.string().utf8();
+        name = nameString.data();
+    }
 
     int style = SkTypeface::kNormal;
     if (fontDescription.weight() >= FontWeightBold)