Title: [102791] trunk/Source/WebCore
- Revision
- 102791
- Author
- [email protected]
- Date
- 2011-12-14 09:26:08 -0800 (Wed, 14 Dec 2011)
Log 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:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (102790 => 102791)
--- trunk/Source/WebCore/ChangeLog 2011-12-14 17:20:27 UTC (rev 102790)
+++ trunk/Source/WebCore/ChangeLog 2011-12-14 17:26:08 UTC (rev 102791)
@@ -1,3 +1,20 @@
+2011-12-14 Philippe Normand <[email protected]>
+
+ [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:
+
2011-12-14 Julien Chaffraix <[email protected]>
Crash in RenderBox::paintBoxDecorations when documentElement has no renderer
Modified: trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp (102790 => 102791)
--- trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp 2011-12-14 17:20:27 UTC (rev 102790)
+++ trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp 2011-12-14 17:26:08 UTC (rev 102791)
@@ -179,8 +179,8 @@
src->priv = priv;
new (priv) WebKitWebAudioSourcePrivate();
- GstPadTemplate* padTemplate = gst_static_pad_template_get(&srcTemplate);
- priv->sourcePad = gst_ghost_pad_new_no_target_from_template("src", padTemplate);
+ GRefPtr<GstPadTemplate> padTemplate = adoptGRef(gst_static_pad_template_get(&srcTemplate));
+ priv->sourcePad = gst_ghost_pad_new_no_target_from_template("src", padTemplate.get());
gst_element_add_pad(GST_ELEMENT(src), priv->sourcePad);
priv->provider = 0;
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp (102790 => 102791)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp 2011-12-14 17:20:27 UTC (rev 102790)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp 2011-12-14 17:26:08 UTC (rev 102791)
@@ -68,6 +68,27 @@
gst_object_unref(GST_OBJECT(ptr));
}
+template <> GRefPtr<GstPadTemplate> adoptGRef(GstPadTemplate* ptr)
+{
+ ASSERT(!ptr || !GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr)));
+ return GRefPtr<GstPadTemplate>(ptr, GRefPtrAdopt);
+}
+
+template <> GstPadTemplate* refGPtr<GstPadTemplate>(GstPadTemplate* ptr)
+{
+ if (ptr) {
+ gst_object_ref(GST_OBJECT(ptr));
+ gst_object_sink(GST_OBJECT(ptr));
+ }
+ return ptr;
+}
+
+template <> void derefGPtr<GstPadTemplate>(GstPadTemplate* ptr)
+{
+ if (ptr)
+ gst_object_unref(GST_OBJECT(ptr));
+}
+
template <> GstCaps* refGPtr<GstCaps>(GstCaps* ptr)
{
if (ptr)
Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h (102790 => 102791)
--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h 2011-12-14 17:20:27 UTC (rev 102790)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h 2011-12-14 17:26:08 UTC (rev 102791)
@@ -25,6 +25,7 @@
typedef struct _GstElement GstElement;
typedef struct _GstPad GstPad;
+typedef struct _GstPadTemplate GstPadTemplate;
typedef struct _GstCaps GstCaps;
typedef struct _GstTask GstTask;
@@ -38,6 +39,10 @@
template<> GstPad* refGPtr<GstPad>(GstPad* ptr);
template<> void derefGPtr<GstPad>(GstPad* ptr);
+template<> GRefPtr<GstPadTemplate> adoptGRef(GstPadTemplate* ptr);
+template<> GstPadTemplate* refGPtr<GstPadTemplate>(GstPadTemplate* ptr);
+template<> void derefGPtr<GstPadTemplate>(GstPadTemplate* ptr);
+
template<> GstCaps* refGPtr<GstCaps>(GstCaps* ptr);
template<> void derefGPtr<GstCaps>(GstCaps* ptr);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes