diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2016-02-10 19:56:59 +0530 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2016-04-06 13:17:48 +0100 |
commit | b42c857c37863ac1c0ca3236a3bcba8ff439cc7d (patch) | |
tree | 0b01e12391d632c24a84123d6221bf0d6c8ad18b | |
parent | 24d2312ed703560ef4805cfc4bf7c67d35603f4e (diff) | |
download | gstreamer-plugins-good-b42c857c37863ac1c0ca3236a3bcba8ff439cc7d.tar.gz |
v4l2: Don't leak v4l2 objects and props on probe errors
-rw-r--r-- | sys/v4l2/gstv4l2deviceprovider.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/v4l2/gstv4l2deviceprovider.c b/sys/v4l2/gstv4l2deviceprovider.c index 63329e64f..9fea0b32d 100644 --- a/sys/v4l2/gstv4l2deviceprovider.c +++ b/sys/v4l2/gstv4l2deviceprovider.c @@ -99,17 +99,17 @@ static GstV4l2Device * gst_v4l2_device_provider_probe_device (GstV4l2DeviceProvider * provider, const gchar * device_path, const gchar * device_name) { - GstV4l2Object *v4l2obj; + GstV4l2Object *v4l2obj = NULL; GstCaps *caps; GstV4l2Device *device = NULL; struct stat st; GstV4l2DeviceType type = GST_V4L2_DEVICE_TYPE_INVALID; 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); @@ -153,7 +153,8 @@ close: destroy: - gst_v4l2_object_destroy (v4l2obj); + if (v4l2obj) + gst_v4l2_object_destroy (v4l2obj); return device; } |