[vlc-commits] filesystem: avoid potential qsort(NULL)

Rémi Denis-Courmont git at videolan.org
Thu Aug 28 21:13:29 CEST 2014


vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug 25 21:35:27 2014 +0300| [b7740617b4c2e085078faf08c938a3a3cbe14efd] | committer: Jean-Baptiste Kempf

filesystem: avoid potential qsort(NULL)

(cherry picked from commit 558e6b78d4c269a2de4a152cd2c72cb685c65027)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 src/text/filesystem.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/text/filesystem.c b/src/text/filesystem.c
index 31d4dc6..4b4d0bb 100644
--- a/src/text/filesystem.c
+++ b/src/text/filesystem.c
@@ -153,7 +153,7 @@ int vlc_loaddir( DIR *dir, char ***namelist,
             num++;
     }
 
-    if (compar != NULL)
+    if (compar != NULL && num > 0)
         qsort (tab, num, sizeof (*tab),
                (int (*)( const void *, const void *))compar);
     *namelist = tab;



More information about the vlc-commits mailing list