Changeset 152397 in webkit


Ignore:
Timestamp:
Jul 4, 2013 5:10:45 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[ATK] Leak: AtkAttributeSet* should be freed
https://bugs.webkit.org/show_bug.cgi?id=118307

Patch by Brian Holt <brian.holt@samsung.com> on 2013-07-04
Reviewed by Christophe Dumez.

Source/WebCore:

Use AtkAttributeSet* instead of GSList*.

  • accessibility/atk/WebKitAccessibleWrapperAtk.cpp:

(webkitAccessibleGetObjectLocale):

Tools:

Fixed memory leaks for AtkAttributeSet by calling
atk_attribute_set_free().

  • DumpRenderTree/atk/AccessibilityControllerAtk.cpp:

(AccessibilityController::childElementById):

  • DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:

(getAtkAttributeSetAsString):
(AccessibilityUIElement::allAttributes):
(AccessibilityUIElement::stringAttributeValue):

  • WebKitTestRunner/InjectedBundle/atk/AccessibilityControllerAtk.cpp:

(WTR::childElementById):

  • WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:

(WTR::getAtkAttributeSetAsString):
(WTR::AccessibilityUIElement::allAttributes):
(WTR::AccessibilityUIElement::stringAttributeValue):

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r152396 r152397  
     12013-07-04  Brian Holt  <brian.holt@samsung.com>
     2
     3        [ATK] Leak: AtkAttributeSet* should be freed
     4        https://bugs.webkit.org/show_bug.cgi?id=118307
     5
     6        Reviewed by Christophe Dumez.
     7
     8        Use AtkAttributeSet* instead of GSList*.
     9
     10        * accessibility/atk/WebKitAccessibleWrapperAtk.cpp:
     11        (webkitAccessibleGetObjectLocale):
     12
    1132013-07-04  Mario Sanchez Prada  <mario.prada@samsung.com>
    214
  • trunk/Source/WebCore/accessibility/atk/WebKitAccessibleWrapperAtk.cpp

    r151831 r152397  
    812812
    813813        AtkAttributeSet* textAttributes = atk_text_get_default_attributes(ATK_TEXT(object));
    814         for (GSList* attributes = textAttributes; attributes; attributes = attributes->next) {
     814        for (AtkAttributeSet* attributes = textAttributes; attributes; attributes = attributes->next) {
    815815            AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(attributes->data);
    816816            if (!strcmp(atkAttribute->name, atk_text_attribute_get_name(ATK_TEXT_ATTR_LANGUAGE))) {
     
    819819            }
    820820        }
    821 
    822821        atk_attribute_set_free(textAttributes);
    823822
  • trunk/Tools/ChangeLog

    r152373 r152397  
     12013-07-04  Brian Holt  <brian.holt@samsung.com>
     2
     3        [ATK] Leak: AtkAttributeSet* should be freed
     4        https://bugs.webkit.org/show_bug.cgi?id=118307
     5
     6        Reviewed by Christophe Dumez.
     7
     8        Fixed memory leaks for AtkAttributeSet by calling
     9        atk_attribute_set_free().
     10
     11        * DumpRenderTree/atk/AccessibilityControllerAtk.cpp:
     12        (AccessibilityController::childElementById):
     13        * DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:
     14        (getAtkAttributeSetAsString):
     15        (AccessibilityUIElement::allAttributes):
     16        (AccessibilityUIElement::stringAttributeValue):
     17        * WebKitTestRunner/InjectedBundle/atk/AccessibilityControllerAtk.cpp:
     18        (WTR::childElementById):
     19        * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
     20        (WTR::getAtkAttributeSetAsString):
     21        (WTR::AccessibilityUIElement::allAttributes):
     22        (WTR::AccessibilityUIElement::stringAttributeValue):
     23
    1242013-07-03  David Farler  <dfarler@apple.com>
    225
  • trunk/Tools/DumpRenderTree/atk/AccessibilityControllerAtk.cpp

    r145014 r152397  
    9494        return 0;
    9595
    96     AtkAttributeSet* attributeSet = atk_object_get_attributes(parent);
    97     for (GSList* attributes = attributeSet; attributes; attributes = attributes->next) {
     96    bool parentFound = false;
     97    AtkAttributeSet* attributeSet(atk_object_get_attributes(parent));
     98    for (AtkAttributeSet* attributes = attributeSet; attributes; attributes = attributes->next) {
    9899        AtkAttribute* attribute = static_cast<AtkAttribute*>(attributes->data);
    99100        if (!strcmp(attribute->name, "html-id")) {
    100101            if (!strcmp(attribute->value, id))
    101                 return parent;
     102                parentFound = true;
    102103            break;
    103104        }
    104105    }
     106    atk_attribute_set_free(attributeSet);
     107
     108    if (parentFound)
     109        return parent;
    105110
    106111    int childCount = atk_object_get_n_accessible_children(parent);
  • trunk/Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp

    r152371 r152397  
    293293}
    294294
    295 gchar* attributeSetToString(AtkAttributeSet* attributeSet)
     295static char* getAtkAttributeSetAsString(AtkObject* accessible)
    296296{
    297297    GString* str = g_string_new(0);
    298     for (GSList* attributes = attributeSet; attributes; attributes = attributes->next) {
     298
     299    AtkAttributeSet* attributeSet = atk_object_get_attributes(accessible);
     300    for (AtkAttributeSet* attributes = attributeSet; attributes; attributes = attributes->next) {
    299301        AtkAttribute* attribute = static_cast<AtkAttribute*>(attributes->data);
    300302        GOwnPtr<gchar> attributeData(g_strconcat(attribute->name, ":", attribute->value, NULL));
     
    303305            g_string_append(str, ", ");
    304306    }
     307    atk_attribute_set_free(attributeSet);
    305308
    306309    return g_string_free(str, FALSE);
     
    309312JSStringRef AccessibilityUIElement::allAttributes()
    310313{
    311     if (!m_element)
    312         return JSStringCreateWithCharacters(0, 0);
    313 
    314     ASSERT(ATK_IS_OBJECT(m_element));
    315     GOwnPtr<gchar> attributeData(attributeSetToString(atk_object_get_attributes(ATK_OBJECT(m_element))));
     314    if (!m_element || !ATK_IS_OBJECT(m_element))
     315        return JSStringCreateWithCharacters(0, 0);
     316
     317    GOwnPtr<char> attributeData(getAtkAttributeSetAsString(ATK_OBJECT(m_element)));
    316318    return JSStringCreateWithUTF8CString(attributeData.get());
    317319}
     
    803805        return JSStringCreateWithCharacters(0, 0);
    804806
    805     for (GSList* atkAttributes = atk_object_get_attributes(ATK_OBJECT(m_element)); atkAttributes; atkAttributes = atkAttributes->next) {
    806         AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(atkAttributes->data);
    807         if (!strcmp(atkAttribute->name, atkAttributeName.utf8().data()))
    808             return JSStringCreateWithUTF8CString(atkAttribute->value);
     807    const char* attributeValue = 0;
     808    AtkAttributeSet* attributeSet = atk_object_get_attributes(ATK_OBJECT(m_element));
     809    for (AtkAttributeSet* attributes = attributeSet; attributes; attributes = attributes->next) {
     810        AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(attributes->data);
     811        if (!strcmp(atkAttribute->name, atkAttributeName.utf8().data())) {
     812            attributeValue = atkAttribute->value;
     813            break;
     814        }
    809815    }
    810 
    811     return JSStringCreateWithCharacters(0, 0);
     816    JSStringRef jsString = attributeValue
     817        ? JSStringCreateWithUTF8CString(attributeValue)
     818        : JSStringCreateWithCharacters(0, 0);
     819    atk_attribute_set_free(attributeSet);
     820
     821    return jsString;
    812822}
    813823
  • trunk/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityControllerAtk.cpp

    r150431 r152397  
    156156        return 0;
    157157
     158    bool parentFound = false;
    158159    AtkAttributeSet* attributeSet = atk_object_get_attributes(parent);
    159     for (GSList* attributes = attributeSet; attributes; attributes = attributes->next) {
     160    for (AtkAttributeSet* attributes = attributeSet; attributes; attributes = attributes->next) {
    160161        AtkAttribute* attribute = static_cast<AtkAttribute*>(attributes->data);
    161162        if (!strcmp(attribute->name, "html-id")) {
    162163            if (!strcmp(attribute->value, id))
    163                 return parent;
     164                parentFound = true;
    164165            break;
    165166        }
    166167    }
     168    atk_attribute_set_free(attributeSet);
     169
     170    if (parentFound)
     171        return parent;
    167172
    168173    int childCount = atk_object_get_n_accessible_children(parent);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp

    r152371 r152397  
    5454}
    5555
    56 static void attributesClear(AtkAttributeSet* attributesSet)
    57 {
    58     for (GSList* attributes = attributesSet; attributes; attributes = attributes->next) {
    59         AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(attributes->data);
    60         g_free(atkAttribute->name);
    61         g_free(atkAttribute->value);
    62         g_free(atkAttribute);
    63     }
    64 }
    65 
    66 static gchar* attributeSetToString(AtkAttributeSet* attributeSet)
    67 {
    68     GOwnPtr<GSList> atkAttributes(attributeSet);
     56static char* getAtkAttributeSetAsString(AtkObject* accessible)
     57{
    6958    GString* str = g_string_new(0);
    70     for (GSList* attributes = atkAttributes.get(); attributes; attributes = attributes->next) {
     59
     60    AtkAttributeSet* attributeSet = atk_object_get_attributes(accessible);
     61    for (AtkAttributeSet* attributes = attributeSet; attributes; attributes = attributes->next) {
    7162        AtkAttribute* attribute = static_cast<AtkAttribute*>(attributes->data);
    7263        GOwnPtr<gchar> attributeData(g_strconcat(attribute->name, ":", attribute->value, NULL));
     
    7566            g_string_append(str, ", ");
    7667    }
    77 
    78     attributesClear(atkAttributes.get());
     68    atk_attribute_set_free(attributeSet);
    7969
    8070    return g_string_free(str, FALSE);
     
    471461        return JSStringCreateWithCharacters(0, 0);
    472462
    473     GOwnPtr<gchar> attributeData(attributeSetToString(atk_object_get_attributes(ATK_OBJECT(m_element.get()))));
     463    GOwnPtr<char> attributeData(getAtkAttributeSetAsString(ATK_OBJECT(m_element.get())));
    474464    return JSStringCreateWithUTF8CString(attributeData.get());
    475465}
     
    484474        return JSStringCreateWithCharacters(0, 0);
    485475
    486     GOwnPtr<gchar> attributeValue;
    487     GOwnPtr<GSList> objectAttributes(atk_object_get_attributes(ATK_OBJECT(m_element.get())));
    488     for (GSList* attributes =  objectAttributes.get(); attributes; attributes = attributes->next) {
     476    const char* attributeValue = 0;
     477    AtkAttributeSet* attributeSet = atk_object_get_attributes(ATK_OBJECT(m_element.get()));
     478    for (AtkAttributeSet* attributes = attributeSet; attributes; attributes = attributes->next) {
    489479        AtkAttribute* atkAttribute = static_cast<AtkAttribute*>(attributes->data);
    490480        if (!strcmp(atkAttribute->name, atkAttributeName.utf8().data())) {
    491             attributeValue.set(g_strdup(atkAttribute->value));
     481            attributeValue = atkAttribute->value;
    492482            break;
    493483        }
    494484    }
    495 
    496     attributesClear(objectAttributes.get());
    497 
    498     return JSStringCreateWithUTF8CString(attributeValue.get());
     485    JSStringRef jsString = attributeValue
     486        ? JSStringCreateWithUTF8CString(attributeValue)
     487        : JSStringCreateWithCharacters(0, 0);
     488    atk_attribute_set_free(attributeSet);
     489
     490    return jsString;
    499491}
    500492
Note: See TracChangeset for help on using the changeset viewer.