bluez: avdtpsrc: fix caps leak in error code paths

https://bugzilla.gnome.org/show_bug.cgi?id=776085
This commit is contained in:
Garima Gaur 2016-12-27 13:45:49 +05:30 committed by Tim-Philipp Müller
parent 3caf16a199
commit 70fbcf9c0f

View file

@ -232,6 +232,7 @@ gst_avdtp_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
value = gst_structure_get_value (structure, "mpegversion"); value = gst_structure_get_value (structure, "mpegversion");
if (!value || !G_VALUE_HOLDS_INT (value)) { if (!value || !G_VALUE_HOLDS_INT (value)) {
GST_ERROR_OBJECT (avdtpsrc, "Failed to get mpegversion"); GST_ERROR_OBJECT (avdtpsrc, "Failed to get mpegversion");
gst_caps_unref (caps);
return NULL; return NULL;
} }
gst_caps_set_simple (caps, "mpegversion", G_TYPE_INT, gst_caps_set_simple (caps, "mpegversion", G_TYPE_INT,
@ -240,6 +241,7 @@ gst_avdtp_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
value = gst_structure_get_value (structure, "channels"); value = gst_structure_get_value (structure, "channels");
if (!value || !G_VALUE_HOLDS_INT (value)) { if (!value || !G_VALUE_HOLDS_INT (value)) {
GST_ERROR_OBJECT (avdtpsrc, "Failed to get channels"); GST_ERROR_OBJECT (avdtpsrc, "Failed to get channels");
gst_caps_unref (caps);
return NULL; return NULL;
} }
gst_caps_set_simple (caps, "channels", G_TYPE_INT, gst_caps_set_simple (caps, "channels", G_TYPE_INT,
@ -248,6 +250,7 @@ gst_avdtp_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
value = gst_structure_get_value (structure, "base-profile"); value = gst_structure_get_value (structure, "base-profile");
if (!value || !G_VALUE_HOLDS_STRING (value)) { if (!value || !G_VALUE_HOLDS_STRING (value)) {
GST_ERROR_OBJECT (avdtpsrc, "Failed to get base-profile"); GST_ERROR_OBJECT (avdtpsrc, "Failed to get base-profile");
gst_caps_unref (caps);
return NULL; return NULL;
} }
gst_caps_set_simple (caps, "base-profile", G_TYPE_STRING, gst_caps_set_simple (caps, "base-profile", G_TYPE_STRING,
@ -261,6 +264,7 @@ gst_avdtp_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter)
value = gst_structure_get_value (structure, "rate"); value = gst_structure_get_value (structure, "rate");
if (!value || !G_VALUE_HOLDS_INT (value)) { if (!value || !G_VALUE_HOLDS_INT (value)) {
GST_ERROR_OBJECT (avdtpsrc, "Failed to get sample rate"); GST_ERROR_OBJECT (avdtpsrc, "Failed to get sample rate");
gst_caps_unref (caps);
return NULL; return NULL;
} }
rate = g_value_get_int (value); rate = g_value_get_int (value);