[vlc-commits] udev: fix unlikely descriptor leak

Rémi Denis-Courmont git at videolan.org
Tue Apr 22 23:11:32 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Apr 23 00:11:05 2014 +0300| [39f55bbf7f4329088970993a5a746d997debe288] | committer: Rémi Denis-Courmont

udev: fix unlikely descriptor leak

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=39f55bbf7f4329088970993a5a746d997debe288
---

 modules/services_discovery/udev.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/modules/services_discovery/udev.c b/modules/services_discovery/udev.c
index 199467f..48050c5 100644
--- a/modules/services_discovery/udev.c
+++ b/modules/services_discovery/udev.c
@@ -535,8 +535,9 @@ static char *disc_get_mrl (struct udev_device *dev)
     val = udev_device_get_property_value (dev, "ID_CDROM_MEDIA_STATE");
     if (val == NULL)
     {   /* Force probing of the disc in the drive if any. */
-        int fd = open (node, O_RDONLY);
-        close (fd);
+        int fd = open (node, O_RDONLY|O_CLOEXEC);
+        if (fd != -1)
+            close (fd);
         return NULL;
     }
     if (!strcmp (val, "blank"))



More information about the vlc-commits mailing list