From 3affb448847bbba658892249208ce2d62e29566c Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Fri, 13 Jul 2012 01:04:22 +1000 Subject: [PATCH] [544/906] fix memory leaks from not g_free()ing string returned by gst_element_get_name --- ext/libvisual/visual-gl.c | 19 +++++++++++++------ gst-libs/gst/gl/gstglfilter.c | 13 +++++++++---- gst-libs/gst/gl/gstglmixer.c | 12 ++++++++---- gst/gl/gstgltestsrc.c | 11 +++++++---- gst/gl/gstglupload.c | 11 +++++++---- 5 files changed, 44 insertions(+), 22 deletions(-) diff --git a/ext/libvisual/visual-gl.c b/ext/libvisual/visual-gl.c index f590d864ff..f9a927a013 100644 --- a/ext/libvisual/visual-gl.c +++ b/ext/libvisual/visual-gl.c @@ -620,9 +620,11 @@ gst_visual_gl_src_query (GstPad * pad, GstQuery * query) case GST_QUERY_CUSTOM: { GstStructure *structure = gst_query_get_structure (query); - res = - g_strcmp0 (gst_element_get_name (visual), - gst_structure_get_name (structure)) == 0; + gchar *name = gst_element_get_name (visual); + + res = g_strcmp0 (name, gst_structure_get_name (structure)) == 0; + g_free (name); + if (!res) res = gst_pad_query_default (pad, query); break; @@ -746,6 +748,7 @@ render_frame (GstVisualGL * visual) VisBuffer *lbuf, *rbuf; guint16 ldata[VISUAL_SAMPLES], rdata[VISUAL_SAMPLES]; guint i; + gcahr *name; /* Read VISUAL_SAMPLES samples per channel */ data = @@ -798,10 +801,11 @@ render_frame (GstVisualGL * visual) * Indeed libprojectM has to unbind it before the first rendering pass * and then rebind it before the final pass. It's done from 2.0.1 */ - if (g_ascii_strncasecmp (gst_element_get_name (GST_ELEMENT (visual)), - "visualglprojectm", 16) == 0 + name = gst_element_get_name (GST_ELEMENT (visual)); + if (g_ascii_strncasecmp (name, "visualglprojectm", 16) == 0 && !HAVE_PROJECTM_TAKING_CARE_OF_EXTERNAL_FBO) glBindFramebufferEXT (GL_FRAMEBUFFER_EXT, 0); + g_free (name); actor_negotiate (visual->display, visual); @@ -1012,6 +1016,7 @@ gst_visual_gl_change_state (GstElement * element, GstStateChange transition) GstStructure *structure = NULL; GstQuery *query = NULL; gboolean isPerformed = FALSE; + gchar *name; if (!parent) { GST_ELEMENT_ERROR (visual, CORE, STATE_CHANGE, (NULL), @@ -1019,8 +1024,10 @@ gst_visual_gl_change_state (GstElement * element, GstStateChange transition) return FALSE; } - structure = gst_structure_new (gst_element_get_name (visual), NULL); + name = gst_element_get_name (visual); + structure = gst_structure_new (name, NULL); query = gst_query_new_application (GST_QUERY_CUSTOM, structure); + g_free (name); isPerformed = gst_element_query (parent, query); diff --git a/gst-libs/gst/gl/gstglfilter.c b/gst-libs/gst/gl/gstglfilter.c index 1b701d5313..92d0e860f9 100644 --- a/gst-libs/gst/gl/gstglfilter.c +++ b/gst-libs/gst/gl/gstglfilter.c @@ -187,10 +187,12 @@ gst_gl_filter_src_query (GstPad * pad, GstObject * parent, GstQuery * query) gst_structure_set (structure, "gstgldisplay", G_TYPE_POINTER, filter->display, NULL); } else { + gchar *name; /* at least one gl element is after in our gl chain */ - res = - g_strcmp0 (gst_element_get_name (parent), - gst_structure_get_name (structure)) == 0; + + name = gst_element_get_name (parent); + res = g_strcmp0 (name, gst_structure_get_name (structure)) == 0; + g_free (name); } if (!res) res = gst_pad_query_default (pad, parent, query); @@ -240,6 +242,7 @@ gst_gl_filter_start (GstBaseTransform * bt) GstStructure *structure = NULL; GstQuery *query = NULL; gboolean isPerformed = FALSE; + gchar *name; if (!parent) { GST_ELEMENT_ERROR (filter, CORE, STATE_CHANGE, (NULL), @@ -247,8 +250,10 @@ gst_gl_filter_start (GstBaseTransform * bt) return FALSE; } - structure = gst_structure_new_empty (gst_element_get_name (filter)); + name = gst_element_get_name (filter); + structure = gst_structure_new_empty (name); query = gst_query_new_custom (GST_QUERY_CUSTOM, structure); + g_free (name); isPerformed = gst_element_query (parent, query); diff --git a/gst-libs/gst/gl/gstglmixer.c b/gst-libs/gst/gl/gstglmixer.c index d666005af0..0852382410 100644 --- a/gst-libs/gst/gl/gstglmixer.c +++ b/gst-libs/gst/gl/gstglmixer.c @@ -215,6 +215,7 @@ gst_gl_mixer_update_src_caps (GstGLMixer * mix) gst_structure_get_int (s, "width", &info.width); gst_structure_get_int (s, "height", &info.height); gst_structure_get_fraction (s, "fraction", &info.fps_n, &info.fps_d); + gst_caps_unref (caps); } caps = gst_video_info_to_caps (&info); @@ -893,10 +894,10 @@ gst_gl_mixer_src_query (GstPad * pad, GstObject * parent, GstQuery * query) * comes from src pad with every display of the sink pads */ GSList *walk = mix->sinkpads; GstStructure *structure = gst_query_writable_structure (query); + gchar *name = gst_element_get_name (mix); - res = - g_strcmp0 (gst_element_get_name (mix), - gst_structure_get_name (structure)) == 0; + res = g_strcmp0 (name, gst_structure_get_name (structure)) == 0; + g_free (name); if (!res) { GstGLDisplay *foreign_display = NULL; @@ -1966,6 +1967,7 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition) { GSList *walk = mix->sinkpads; gint i = 0; + gchar *name; GstElement *parent = GST_ELEMENT (gst_element_get_parent (mix)); GstStructure *structure = NULL; @@ -1978,7 +1980,9 @@ gst_gl_mixer_change_state (GstElement * element, GstStateChange transition) return FALSE; } - structure = gst_structure_new_empty (gst_element_get_name (mix)); + name = gst_element_get_name (mix); + structure = gst_structure_new_empty (name); + g_free (name); query = gst_query_new_custom (GST_QUERY_CUSTOM, structure); /* retrieve the gldisplay that is owned by gl elements after the gl mixer */ diff --git a/gst/gl/gstgltestsrc.c b/gst/gl/gstgltestsrc.c index 351299174e..385bd325aa 100644 --- a/gst/gl/gstgltestsrc.c +++ b/gst/gl/gstgltestsrc.c @@ -318,9 +318,9 @@ gst_gl_test_src_src_query (GstPad * pad, GstObject * object, GstQuery * query) case GST_QUERY_CUSTOM: { const GstStructure *structure = gst_query_get_structure (query); - res = - g_strcmp0 (gst_element_get_name (object), - gst_structure_get_name (structure)) == 0; + gchar *name = gst_element_get_name (object); + res = g_strcmp0 (name, gst_structure_get_name (structure)) == 0; + g_free (name); break; } default: @@ -536,6 +536,7 @@ gst_gl_test_src_start (GstBaseSrc * basesrc) GstStructure *structure = NULL; GstQuery *query = NULL; gboolean isPerformed = FALSE; + gchar *name; if (!parent) { GST_ELEMENT_ERROR (src, CORE, STATE_CHANGE, (NULL), @@ -543,8 +544,10 @@ gst_gl_test_src_start (GstBaseSrc * basesrc) return FALSE; } - structure = gst_structure_new_empty (gst_element_get_name (src)); + name = gst_element_get_name (src); + structure = gst_structure_new_empty (name); query = gst_query_new_custom (GST_QUERY_CUSTOM, structure); + g_free (name); isPerformed = gst_element_query (parent, query); diff --git a/gst/gl/gstglupload.c b/gst/gl/gstglupload.c index 05db0bca96..2970ea9c84 100644 --- a/gst/gl/gstglupload.c +++ b/gst/gl/gstglupload.c @@ -225,9 +225,9 @@ gst_gl_upload_src_query (GstPad * pad, GstObject * object, GstQuery * query) case GST_QUERY_CUSTOM: { const GstStructure *structure = gst_query_get_structure (query); - res = - g_strcmp0 (gst_element_get_name (object), - gst_structure_get_name (structure)) == 0; + gchar *name = gst_element_get_name (object); + res = g_strcmp0 (name, gst_structure_get_name (structure)) == 0; + g_free (name); if (!res) res = gst_pad_query_default (pad, object, query); break; @@ -258,6 +258,7 @@ gst_gl_upload_start (GstBaseTransform * bt) GstStructure *structure = NULL; GstQuery *query = NULL; gboolean isPerformed = FALSE; + gchar *name; if (!parent) { GST_ELEMENT_ERROR (upload, CORE, STATE_CHANGE, (NULL), @@ -265,8 +266,10 @@ gst_gl_upload_start (GstBaseTransform * bt) return FALSE; } - structure = gst_structure_new_empty (gst_element_get_name (upload)); + name = gst_element_get_name (upload); + structure = gst_structure_new_empty (name); query = gst_query_new_custom (GST_QUERY_CUSTOM, structure); + g_free (name); isPerformed = gst_element_query (parent, query);