[Bug 760821] tracerrecord: Fix memory leaks and mishandlings
GStreamer (GNOME Bugzilla)
bugzilla at gnome.org
Thu Jan 21 15:22:54 PST 2016
https://bugzilla.gnome.org/show_bug.cgi?id=760821
--- Comment #23 from Tim-Philipp Müller <t.i.m at zen.co.uk> ---
Comment on attachment 319529
--> https://bugzilla.gnome.org/attachment.cgi?id=319529
don't leak the sub structures
>Subject: [PATCH] tracerrecord: don't leak the spec structures
>
>Change the gst_tracer_record_new() api to take the parameters the make the
>spec structure directly. This allows us to own the top-level structure and
>also collect the args so that we can take ownership of the sub-structures.
>
>Fixes #760821
For what it's worth, these days we just put the full bug url to the bug there
:)
>+ while (firstfield) {
>+ GValue val = { 0, };
>+
>+ id = g_quark_from_string (firstfield);
>+ type = va_arg (varargs, GType);
>+
>+ G_VALUE_COLLECT_INIT (&val, type, varargs, G_VALUE_NOCOPY_CONTENTS, &err);
>+ if (G_UNLIKELY (err)) {
>+ g_critical ("%s", err);
>+ break;
>+ }
>+ gst_structure_id_set_value (structure, id, &val);
>+ gst_structure_free (g_value_get_boxed (&val));
>+ g_value_unset (&val);
>+
>+ firstfield = va_arg (varargs, gchar *);
>+ }
>+ }
gst_structure_id_set_value() + g_value_unset() could be simplified to
gst_structure_id_take_value().
We'd also need to clear the G_VALUE_NOCOPY_CONTENTS flag from
value.data[1].v_uint then, so the struct gets freed properly with the value
later, and the gst_structure_free() is not required anymore then.
--
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
More information about the gstreamer-bugs
mailing list