[vlc-commits] filesystem: fix invalid conversions in vlc_scandir()

Rémi Denis-Courmont git at videolan.org
Tue Jan 15 17:43:30 CET 2019


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jan 15 18:39:10 2019 +0200| [e4d4a57831e75561ee7a1af3c39584803ba61794] | committer: Rémi Denis-Courmont

filesystem: fix invalid conversions in vlc_scandir()

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

 src/text/filesystem.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/text/filesystem.c b/src/text/filesystem.c
index 9917e30f91..3e7af86d0c 100644
--- a/src/text/filesystem.c
+++ b/src/text/filesystem.c
@@ -105,6 +105,14 @@ static int dummy_select( const char *str )
     return 1;
 }
 
+static int compar_void(const void *a, const void *b, void *data)
+{
+    const char *sa = a, *sb = b;
+    int (*cmp)(const char **, const char **) = data;
+
+    return cmp(&sa, &sb);
+}
+
 /**
  * Does the same as vlc_scandir(), but takes an open directory pointer
  * instead of a directory path.
@@ -153,8 +161,7 @@ int vlc_loaddir( DIR *dir, char ***namelist,
     }
 
     if (compar != NULL && num > 0)
-        qsort (tab, num, sizeof (*tab),
-               (int (*)( const void *, const void *))compar);
+        qsort_r(tab, num, sizeof (*tab), compar_void, compar);
     *namelist = tab;
     return num;
 



More information about the vlc-commits mailing list