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
1 changed files with 2 additions and 1 deletions

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