1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-29 11:12:56 +00:00

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.
This commit is contained in:
Ben Boeckel 2014-08-27 18:12:43 -04:00 committed by wm4
parent a95cfac078
commit e023524481

View File

@ -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;
}