From c56eb21a82617f2cc54b97dbfb4fc64ba428851c Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Wed, 13 Sep 2017 11:52:09 -0400 Subject: [PATCH] v4l2object: Don't leak the par value --- sys/v4l2/gstv4l2object.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 57d7b38404..0ececf8b4e 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -668,13 +668,17 @@ gst_v4l2_object_set_property_helper (GstV4l2Object * v4l2object, break; } case PROP_PIXEL_ASPECT_RATIO: - g_free (v4l2object->par); + if (v4l2object->par) { + g_value_unset (v4l2object->par); + g_free (v4l2object->par); + } v4l2object->par = g_new0 (GValue, 1); g_value_init (v4l2object->par, GST_TYPE_FRACTION); if (!g_value_transform (value, v4l2object->par)) { g_warning ("Could not transform string to aspect ratio"); gst_value_set_fraction (v4l2object->par, 1, 1); } + GST_DEBUG_OBJECT (v4l2object->element, "set PAR to %d/%d", gst_value_get_fraction_numerator (v4l2object->par), gst_value_get_fraction_denominator (v4l2object->par)); @@ -904,6 +908,12 @@ gst_v4l2_object_close (GstV4l2Object * v4l2object) gst_v4l2_object_clear_format_list (v4l2object); } + if (v4l2object->par) { + g_value_unset (v4l2object->par); + g_free (v4l2object->par); + v4l2object->par = NULL; + } + return TRUE; }