Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

playlist_save: fix dir may not exist

Attempting to save a playlist to a dir that does
not exist would make playlist_save panic.

https://forums.rockbox.org/index.php/topic,55241

Change-Id: Ibf55255949782315e997733b519c590ac53221a2

+18 -2
+18 -2
apps/menus/playlist_menu.c
··· 39 39 #include "playlist_catalog.h" 40 40 #include "splash.h" 41 41 #include "general.h" 42 + #include "pathfuncs.h" 43 + #include "dir.h" 42 44 43 45 /* load a screen to save the playlist passed in (or current playlist if NULL is passed) */ 44 46 int save_playlist_screen(struct playlist_info* playlist) ··· 72 74 if (len <= 1) /* root or dynamic playlist */ 73 75 create_numbered_filename(temp, directoryonly, PLAYLIST_UNTITLED_PREFIX, ".m3u8", 74 76 1 IF_CNFN_NUM_(, NULL)); 75 - else if (!strcmp((temp + len - 1), "/")) /* dir playlists other than root */ 77 + else if (temp[len - 1] == PATH_SEPCH /* dir playlists other than root */ 78 + && temp[len] == '\0') 76 79 { 77 80 temp[len - 1] = '\0'; 78 81 79 - if ((p = strrchr(temp, '/'))) /* use last path component as playlist name */ 82 + if ((p = strrchr(temp, PATH_SEPCH))) /* use last path component as playlist name */ 80 83 { 81 84 strlcat(directoryonly, p, sizeof(directoryonly)); 82 85 strlcat(directoryonly, ".m3u8", sizeof(directoryonly)); ··· 91 94 playlist ? playlist->filename : 92 95 playlist_get_current()->filename)) 93 96 { 97 + /* Create dir if necessary */ 98 + if ((p = strrchr(temp, PATH_SEPCH)) && p != (char *) temp) 99 + { 100 + *p = '\0'; 101 + 102 + if (!dir_exists(temp) && mkdir(temp) < 0) 103 + { 104 + splashf(HZ, ID2P(LANG_CATALOG_NO_DIRECTORY), temp); 105 + return 0; 106 + } 107 + *p = PATH_SEPCH; 108 + } 109 + 94 110 playlist_save(playlist, temp); 95 111 96 112 /* reload in case playlist was saved to cwd */