[544/906] fix memory leaks from not g_free()ing string returned by gst_element_get_name

This commit is contained in:
Matthew Waters 2012-07-13 01:04:22 +10:00
parent 972cd421c7
commit 3affb44884
5 changed files with 44 additions and 22 deletions

View file

@ -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);

View file

@ -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);

View file

@ -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 */

View file

@ -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);

View file

@ -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);