Changeset 41762 in webkit


Ignore:
Timestamp:
Mar 17, 2009 7:43:32 AM (15 years ago)
Author:
xan@webkit.org
Message:

2009-03-16 Xan Lopez <xlopez@igalia.com>

Reviewed by Holger Freyther.

https://bugs.webkit.org/show_bug.cgi?id=24592
[GTK] Crash in FcPatternHash

Sanitize memory management in gtk fonts.

Release memory allocated by FontPlatformDataGtk in its own
destructor instead of doing it from other classes, and add copy
constructor and '=' operator to be able to track referenced
objects properly.

  • platform/graphics/gtk/FontPlatformData.h:
  • platform/graphics/gtk/FontPlatformDataGtk.cpp: (WebCore::FontPlatformData::operator=): (WebCore::FontPlatformData::FontPlatformData): (WebCore::FontPlatformData::~FontPlatformData):
  • platform/graphics/gtk/SimpleFontDataGtk.cpp: (WebCore::SimpleFontData::platformDestroy):
Location:
trunk/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r41761 r41762  
     12009-03-16  Xan Lopez  <xlopez@igalia.com>
     2
     3        Reviewed by Holger Freyther.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=24592
     6        [GTK] Crash in FcPatternHash
     7
     8        Sanitize memory management in gtk fonts.
     9
     10        Release memory allocated by FontPlatformDataGtk in its own
     11        destructor instead of doing it from other classes, and add copy
     12        constructor and '=' operator to be able to track referenced
     13        objects properly.
     14
     15        * platform/graphics/gtk/FontPlatformData.h:
     16        * platform/graphics/gtk/FontPlatformDataGtk.cpp:
     17        (WebCore::FontPlatformData::operator=):
     18        (WebCore::FontPlatformData::FontPlatformData):
     19        (WebCore::FontPlatformData::~FontPlatformData):
     20        * platform/graphics/gtk/SimpleFontDataGtk.cpp:
     21        (WebCore::SimpleFontData::platformDestroy):
     22
    1232009-03-17  Ariya Hidayat  <ariya.hidayat@nokia.com>
    224
  • trunk/WebCore/platform/graphics/gtk/FontPlatformData.h

    r36309 r41762  
    7575    FontPlatformData(float size, bool bold, bool italic);
    7676    FontPlatformData(cairo_font_face_t* fontFace, int size, bool bold, bool italic);
     77    FontPlatformData(const FontPlatformData&);
    7778
    7879    ~FontPlatformData();
     
    9697
    9798    bool operator==(const FontPlatformData&) const;
     99    FontPlatformData& operator=(const FontPlatformData&);
    98100    bool isHashTableDeletedValue() const {
    99101#if defined(USE_FREETYPE)
  • trunk/WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp

    r36309 r41762  
    44 * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
    55 * Copyright (C) 2007 Holger Hans Peter Freyther
     6 * Copyright (C) 2009 Igalia S.L.
    67 * All rights reserved.
    78 *
     
    162163}
    163164
     165FontPlatformData& FontPlatformData::operator=(const FontPlatformData& other)
     166{
     167    // Check for self-assignment.
     168    if (this == &other)
     169        return *this;
     170
     171    m_size = other.m_size;
     172    m_syntheticBold = other.m_syntheticBold;
     173    m_syntheticOblique = other.m_syntheticOblique;
     174
     175    if (other.m_scaledFont)
     176        cairo_scaled_font_reference (other.m_scaledFont);
     177    if (m_scaledFont)
     178        cairo_scaled_font_destroy(m_scaledFont);
     179    m_scaledFont = other.m_scaledFont;
     180
     181    if (other.m_pattern)
     182        FcPatternReference(other.m_pattern);
     183    if (m_pattern)
     184        FcPatternDestroy(m_pattern);
     185    m_pattern = other.m_pattern;
     186
     187    if (m_fallbacks) {
     188        FcFontSetDestroy(m_fallbacks);
     189        // This will be re-created on demand.
     190        m_fallbacks = 0;
     191    }
     192
     193    return *this;
     194}
     195
     196FontPlatformData::FontPlatformData(const FontPlatformData& other)
     197    : m_pattern(0)
     198    , m_fallbacks(0)
     199    , m_scaledFont(0)
     200{
     201    *this = other;
     202}
     203
    164204bool FontPlatformData::init()
    165205{
     
    177217FontPlatformData::~FontPlatformData()
    178218{
     219    if (m_pattern && ((FcPattern*)-1 != m_pattern)) {
     220        FcPatternDestroy(m_pattern);
     221        m_pattern = 0;
     222    }
     223
     224    if (m_fallbacks) {
     225        FcFontSetDestroy(m_fallbacks);
     226        m_fallbacks = 0;
     227    }
     228
     229    if (m_scaledFont) {
     230        cairo_scaled_font_destroy(m_scaledFont);
     231        m_scaledFont = 0;
     232    }
    179233}
    180234
  • trunk/WebCore/platform/graphics/gtk/SimpleFontDataGtk.cpp

    r41246 r41762  
    6565    delete m_smallCapsFontData;
    6666    m_smallCapsFontData = 0;
    67 
    68     if (isCustomFont())
    69         return;
    70 
    71     if (m_font.m_pattern && ((FcPattern*)-1 != m_font.m_pattern)) {
    72         FcPatternDestroy(m_font.m_pattern);
    73         m_font.m_pattern = 0;
    74     }
    75 
    76     if (m_font.m_fallbacks) {
    77         FcFontSetDestroy(m_font.m_fallbacks);
    78         m_font.m_fallbacks = 0;
    79     }
    80 
    81     if (m_font.m_scaledFont) {
    82         cairo_scaled_font_destroy(m_font.m_scaledFont);
    83         m_font.m_scaledFont = 0;
    84     }
    8567}
    8668
Note: See TracChangeset for help on using the changeset viewer.