v4l2object: Don't leak the par value

This commit is contained in:
Nicolas Dufresne 2017-09-13 11:52:09 -04:00
parent 3ea2621036
commit c56eb21a82

View file

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