[vlc-commits] bluray: check setmntent return value.

Konstantin Pavlov git at videolan.org
Tue Dec 26 00:18:17 CET 2017


vlc/vlc-3.0 | branch: master | Konstantin Pavlov <thresh at videolan.org> | Tue Dec 26 02:03:31 2017 +0300| [0e96c458f307aecdc13b3fac5afc039be8eae1a8] | committer: Konstantin Pavlov

bluray: check setmntent return value.

(cherry picked from commit b73e9de8812273ef295398a7aa3e41a5d73899ae)
Signed-off-by: Konstantin Pavlov <thresh at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=0e96c458f307aecdc13b3fac5afc039be8eae1a8
---

 modules/access/bluray.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/modules/access/bluray.c b/modules/access/bluray.c
index cb1986fa98..082fefae25 100644
--- a/modules/access/bluray.c
+++ b/modules/access/bluray.c
@@ -297,17 +297,19 @@ static void FindMountPoint(char **file)
     struct stat st;
     if (lstat (bd_device, &st) == 0 && S_ISBLK (st.st_mode)) {
         FILE *mtab = setmntent ("/proc/self/mounts", "r");
-        struct mntent *m, mbuf;
-        char buf [8192];
-
-        while ((m = getmntent_r (mtab, &mbuf, buf, sizeof(buf))) != NULL) {
-            if (!strcmp (m->mnt_fsname, bd_device)) {
-                free(device);
-                *file = strdup(m->mnt_dir);
-                break;
+        if (mtab) {
+            struct mntent *m, mbuf;
+            char buf [8192];
+
+            while ((m = getmntent_r (mtab, &mbuf, buf, sizeof(buf))) != NULL) {
+                if (!strcmp (m->mnt_fsname, bd_device)) {
+                    free(device);
+                    *file = strdup(m->mnt_dir);
+                    break;
+                }
             }
+            endmntent (mtab);
         }
-        endmntent (mtab);
     }
     free(bd_device);
 



More information about the vlc-commits mailing list