Changeset 52492 in webkit


Ignore:
Timestamp:
Dec 22, 2009 10:51:00 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-22 Kwang Yul Seo <skyul@company100.net>

Reviewed by Darin Adler.

Allocate RemoteFontStream on the heap
https://bugs.webkit.org/show_bug.cgi?id=32850

RemoteFontStream is allocated on the stack, so its memory is freed
immediately when FontCustomPlatformData::createFontCustomPlatformData
returns.

SkTypeface::CreateFromStream increments the reference count, but it keeps
the pointer to the memory allocated on the stack which is not valid
anymore.

RemoteFontStream is a descendant of SkRefCount and SkRefCount::unref
invokes SkDELETE(this) internally once the reference count reaches zero.
This means that SkRefCount-ed instances must be allocated on the heap.

  • platform/graphics/chromium/FontCustomPlatformData.cpp: (WebCore::createFontCustomPlatformData):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r52491 r52492  
     12009-12-22  Kwang Yul Seo  <skyul@company100.net>
     2
     3        Reviewed by Darin Adler.
     4
     5        Allocate RemoteFontStream on the heap
     6        https://bugs.webkit.org/show_bug.cgi?id=32850
     7
     8        RemoteFontStream is allocated on the stack, so its memory is freed
     9        immediately when FontCustomPlatformData::createFontCustomPlatformData
     10        returns.
     11
     12        SkTypeface::CreateFromStream increments the reference count, but it keeps
     13        the pointer to the memory allocated on the stack which is not valid
     14        anymore.
     15
     16        RemoteFontStream is a descendant of SkRefCount and SkRefCount::unref
     17        invokes SkDELETE(this) internally once the reference count reaches zero.
     18        This means that SkRefCount-ed instances must be allocated on the heap.
     19
     20        * platform/graphics/chromium/FontCustomPlatformData.cpp:
     21        (WebCore::createFontCustomPlatformData):
     22
    1232009-12-22  Kwang Yul Seo  <skyul@company100.net>
    224
  • trunk/WebCore/platform/graphics/chromium/FontCustomPlatformData.cpp

    r51623 r52492  
    191191    return new FontCustomPlatformData(fontReference, fontName);
    192192#elif PLATFORM(LINUX)
    193     RemoteFontStream stream(buffer);
    194     SkTypeface* typeface = SkTypeface::CreateFromStream(&stream);
     193    RemoteFontStream* stream = new RemoteFontStream(buffer);
     194    SkTypeface* typeface = SkTypeface::CreateFromStream(stream);
    195195    if (!typeface)
    196196        return 0;
Note: See TracChangeset for help on using the changeset viewer.