summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2016-02-10 19:56:59 +0530
committerTim-Philipp Müller <tim@centricular.com>2016-04-04 20:31:43 +0100
commita5369c6be36fb22b505bb765f987212b39bcf408 (patch)
treeb3ffb191ccd3981cdda596acca371c27e5ba719e /sys
parent03e2655f7090f743bbf4f71b5ca5b191c4b2d376 (diff)
v4l2: Don't leak v4l2 objects and props on probe errors
Diffstat (limited to 'sys')
-rw-r--r--sys/v4l2/gstv4l2deviceprovider.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/v4l2/gstv4l2deviceprovider.c b/sys/v4l2/gstv4l2deviceprovider.c
index e606f846b..d521838fc 100644
--- a/sys/v4l2/gstv4l2deviceprovider.c
+++ b/sys/v4l2/gstv4l2deviceprovider.c
@@ -100,7 +100,7 @@ static GstV4l2Device *
gst_v4l2_device_provider_probe_device (GstV4l2DeviceProvider * provider,
const gchar * device_path, const gchar * device_name, GstStructure * props)
{
- GstV4l2Object *v4l2obj;
+ GstV4l2Object *v4l2obj = NULL;
GstCaps *caps;
GstV4l2Device *device = NULL;
struct stat st;
@@ -109,10 +109,10 @@ gst_v4l2_device_provider_probe_device (GstV4l2DeviceProvider * provider,
g_return_val_if_fail (props != NULL, NULL);
if (stat (device_path, &st) == -1)
- return NULL;
+ goto destroy;
if (!S_ISCHR (st.st_mode))
- return NULL;
+ goto destroy;
v4l2obj = gst_v4l2_object_new ((GstElement *) provider,
V4L2_BUF_TYPE_VIDEO_CAPTURE, device_path, NULL, NULL, NULL);
@@ -172,7 +172,8 @@ close:
destroy:
- gst_v4l2_object_destroy (v4l2obj);
+ if (v4l2obj)
+ gst_v4l2_object_destroy (v4l2obj);
if (props)
gst_structure_free (props);