Fixed crash on absent or invalid jukebox directory (testing scandir() return value)

This commit is contained in:
md2211 2007-11-05 13:41:20 +00:00
parent a4beacd08a
commit c6407e0c2d
2 changed files with 8 additions and 6 deletions

View file

@ -3,6 +3,7 @@ D2X-Rebirth Changelog
20071105
--------
arch/carbon/conf.h, English.lproj/InfoPlist.strings, d2x-Info.plist, d2xgl-Info.plist: update Mac version info, set SHAREPATH to application folder for Mac OS X
arch/sdl/jukebox.c: Fixed crash on absent or invalid jukebox directory
20071103
--------

View file

@ -89,12 +89,13 @@ void jukebox_load() {
JukeboxSongs = dl_init();
count = scandir(jukebox_path, &files, file_select, alphasort);
if (count > 0) {
printf("Jukebox: %d music file(s) found in %s\n", count, jukebox_path);
for (i=0; i<count; i++) dl_add(JukeboxSongs, files[i]->d_name);
jukebox_loaded = 1;
}
else { printf("Jukebox music could not be found!\n"); }
}
}
else { printf("Jukebox already loaded\n"); }
}