Changeset 102791 in webkit


Ignore:
Timestamp:
Dec 14, 2011 9:26:08 AM (12 years ago)
Author:
Philippe Normand
Message:

[GStreamer] padTemplate leak in webkitwebaudiosrc
https://bugs.webkit.org/show_bug.cgi?id=74495

Reviewed by Martin Robinson.

Use a GstPadTemplate smart pointer in webkit_web_audio_src_init to
avoid a memory leak after the ghost pad creation.

  • platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:

(webkit_web_audio_src_init):

  • platform/graphics/gstreamer/GRefPtrGStreamer.cpp:

(WTF::adoptGRef):
(WTF::GstPadTemplate):

  • platform/graphics/gstreamer/GRefPtrGStreamer.h:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r102787 r102791  
     12011-12-14  Philippe Normand  <pnormand@igalia.com>
     2
     3        [GStreamer] padTemplate leak in webkitwebaudiosrc
     4        https://bugs.webkit.org/show_bug.cgi?id=74495
     5
     6        Reviewed by Martin Robinson.
     7
     8        Use a GstPadTemplate smart pointer in webkit_web_audio_src_init to
     9        avoid a memory leak after the ghost pad creation.
     10
     11        * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
     12        (webkit_web_audio_src_init):
     13        * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
     14        (WTF::adoptGRef):
     15        (WTF::GstPadTemplate):
     16        * platform/graphics/gstreamer/GRefPtrGStreamer.h:
     17
    1182011-12-14  Julien Chaffraix  <jchaffraix@webkit.org>
    219
  • trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp

    r101138 r102791  
    180180    new (priv) WebKitWebAudioSourcePrivate();
    181181
    182     GstPadTemplate* padTemplate = gst_static_pad_template_get(&srcTemplate);
    183     priv->sourcePad = gst_ghost_pad_new_no_target_from_template("src", padTemplate);
     182    GRefPtr<GstPadTemplate> padTemplate = adoptGRef(gst_static_pad_template_get(&srcTemplate));
     183    priv->sourcePad = gst_ghost_pad_new_no_target_from_template("src", padTemplate.get());
    184184    gst_element_add_pad(GST_ELEMENT(src), priv->sourcePad);
    185185
  • trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp

    r101138 r102791  
    6969}
    7070
     71template <> GRefPtr<GstPadTemplate> adoptGRef(GstPadTemplate* ptr)
     72{
     73    ASSERT(!ptr || !GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr)));
     74    return GRefPtr<GstPadTemplate>(ptr, GRefPtrAdopt);
     75}
     76
     77template <> GstPadTemplate* refGPtr<GstPadTemplate>(GstPadTemplate* ptr)
     78{
     79    if (ptr) {
     80        gst_object_ref(GST_OBJECT(ptr));
     81        gst_object_sink(GST_OBJECT(ptr));
     82    }
     83    return ptr;
     84}
     85
     86template <> void derefGPtr<GstPadTemplate>(GstPadTemplate* ptr)
     87{
     88    if (ptr)
     89        gst_object_unref(GST_OBJECT(ptr));
     90}
     91
    7192template <> GstCaps* refGPtr<GstCaps>(GstCaps* ptr)
    7293{
  • trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h

    r101138 r102791  
    2626typedef struct _GstElement GstElement;
    2727typedef struct _GstPad GstPad;
     28typedef struct _GstPadTemplate GstPadTemplate;
    2829typedef struct _GstCaps GstCaps;
    2930typedef struct _GstTask GstTask;
     
    3940template<> void derefGPtr<GstPad>(GstPad* ptr);
    4041
     42template<> GRefPtr<GstPadTemplate> adoptGRef(GstPadTemplate* ptr);
     43template<> GstPadTemplate* refGPtr<GstPadTemplate>(GstPadTemplate* ptr);
     44template<> void derefGPtr<GstPadTemplate>(GstPadTemplate* ptr);
     45
    4146template<> GstCaps* refGPtr<GstCaps>(GstCaps* ptr);
    4247template<> void derefGPtr<GstCaps>(GstCaps* ptr);
Note: See TracChangeset for help on using the changeset viewer.