summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <mathstuf@gmail.com>2014-08-27 18:12:43 -0400
committerwm4 <wm4@nowhere>2014-08-28 12:02:09 +0200
commite0235244812c011b9d0cc589c27ee65e5223bec6 (patch)
tree62164d01d0829922df4e51c374f76c06b3adfb0e
parenta95cfac07876a134f43d1e033720c9e5d847b5be (diff)
downloadmpv-e0235244812c011b9d0cc589c27ee65e5223bec6.tar.bz2
mpv-e0235244812c011b9d0cc589c27ee65e5223bec6.tar.xz
player: don't sort a NULL list
This can occur if the directory does not have any files in it which causes files to never be non-NULL for qsort.
-rw-r--r--player/scripting.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/player/scripting.c b/player/scripting.c
index 0393427bef..1efe6389f6 100644
--- a/player/scripting.c
+++ b/player/scripting.c
@@ -151,7 +151,8 @@ static char **list_script_files(void *talloc_ctx, char *path)
MP_TARRAY_APPEND(talloc_ctx, files, count, fname);
}
closedir(dp);
- qsort(files, count, sizeof(char *), compare_filename);
+ if (files)
+ qsort(files, count, sizeof(char *), compare_filename);
MP_TARRAY_APPEND(talloc_ctx, files, count, NULL);
return files;
}