Changeset 149666 in webkit


Ignore:
Timestamp:
May 7, 2013 12:42:15 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] Initialize WebKitWebPlugin path to prevent double-free
https://bugs.webkit.org/show_bug.cgi?id=115624

Patch by Tomas Popela <tpopela@redhat.com> on 2013-05-07
Reviewed by Carlos Garcia Campos.

Use GOwnPtr for WebKitWebPlugin path to prevent double-free
situations. Also use GOwnPtr for GError in webkit_web_plugin_get_path.

  • webkit/webkitwebplugin.cpp:

(webkit_web_plugin_finalize):
(webkit_web_plugin_get_path):

  • webkit/webkitwebpluginprivate.h:
Location:
trunk/Source/WebKit/gtk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/gtk/ChangeLog

    r149588 r149666  
     12013-05-07  Tomas Popela  <tpopela@redhat.com>
     2
     3        [GTK] Initialize WebKitWebPlugin path to prevent double-free
     4        https://bugs.webkit.org/show_bug.cgi?id=115624
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Use GOwnPtr for WebKitWebPlugin path to prevent double-free
     9        situations. Also use GOwnPtr for GError in webkit_web_plugin_get_path.
     10
     11        * webkit/webkitwebplugin.cpp:
     12        (webkit_web_plugin_finalize):
     13        (webkit_web_plugin_get_path):
     14        * webkit/webkitwebpluginprivate.h:
     15
    1162013-05-06  Zan Dobersek  <zdobersek@igalia.com>
    217
  • trunk/Source/WebKit/gtk/webkit/webkitwebplugin.cpp

    r148935 r149666  
    6464    WebKitWebPluginPrivate* priv = plugin->priv;
    6565
    66     g_free(priv->path);
    67 
    6866    g_slist_foreach(priv->mimeTypes, (GFunc)freeMIMEType, 0);
    6967    g_slist_free(priv->mimeTypes);
     
    192190
    193191    if (priv->path)
    194         return priv->path;
    195 
    196     GError* error = 0;
    197     priv->path = g_filename_from_utf8(priv->corePlugin->path().utf8().data(), -1, 0, 0, &error);
     192        return priv->path.get();
     193
     194    GOwnPtr<GError> error;
     195    priv->path.set(g_filename_from_utf8(priv->corePlugin->path().utf8().data(), -1, 0, 0, &error.outPtr()));
    198196
    199197    if (!error)
    200         return priv->path;
     198        return priv->path.get();
    201199
    202200    // In the unlikely case the convertion fails, report the error and make sure we free
    203201    // any partial convertion that ended up in the variable.
    204     g_free(priv->path);
    205     priv->path = 0;
     202    priv->path.clear();
    206203
    207204    g_warning("Failed to convert '%s' to system filename encoding: %s", priv->corePlugin->path().utf8().data(), error->message);
    208 
    209     g_clear_error(&error);
    210205
    211206    return 0;
  • trunk/Source/WebKit/gtk/webkit/webkitwebpluginprivate.h

    r95901 r149666  
    2222#include "webkitwebplugin.h"
    2323#include <glib-object.h>
     24#include <wtf/gobject/GOwnPtr.h>
    2425#include <wtf/text/CString.h>
    2526
     
    3940    CString name;
    4041    CString description;
    41     char* path;
     42    GOwnPtr<char> path;
    4243    GSList* mimeTypes;
    4344};
Note: See TracChangeset for help on using the changeset viewer.