summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-19 20:31:33 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-05-19 20:31:33 +0200
commit7dedf440d149b7f7394c7810d9ca6e42ee89b7bd (patch)
tree0c3458f9552fcf1d5e7faef018e25b99111cc677 /playlist.c
parent78475a5a791b11218c2ecd9253d0a839256ba5fb (diff)
limit to 100 max playlists; fixed playlist name corruption/shuffling
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/playlist.c b/playlist.c
index 3478ffaf..f5a667c1 100644
--- a/playlist.c
+++ b/playlist.c
@@ -187,7 +187,7 @@ plt_gen_conf (void) {
playlist_t *p = playlists_head;
for (i = 0; i < cnt; i++, p = p->next) {
char s[100];
- snprintf (s, sizeof (s), "playlist.tab.%d", i);
+ snprintf (s, sizeof (s), "playlist.tab.%02d", i);
conf_set_str (s, p->title);
}
PLT_UNLOCK;
@@ -245,6 +245,10 @@ int
plt_add (int before, const char *title) {
assert (before >= 0);
trace ("plt_add\n");
+ if (plt_get_count () >= 100) {
+ fprintf (stderr, "can't create more than 100 playlists. sorry.\n");
+ return -1;
+ }
playlist_t *plt = malloc (sizeof (playlist_t));
memset (plt, 0, sizeof (playlist_t));
plt->title = strdup (title);
@@ -2201,7 +2205,9 @@ pl_load_all (void) {
fprintf (stderr, "error: cannot make string with default playlist path\n");
return -1;
}
- plt_add (plt_get_count (), "Default");
+ if (plt_add (plt_get_count (), "Default") < 0) {
+ return -1;
+ }
return pl_load (defpl);
}
trace ("pl_load_all started\n");
@@ -2211,7 +2217,9 @@ pl_load_all (void) {
while (it) {
fprintf (stderr, "INFO: loading playlist %s\n", it->value);
if (!err) {
- plt_add (plt_get_count (), it->value);
+ if (plt_add (plt_get_count (), it->value) < 0) {
+ return -1;
+ }
plt_set_curr (plt_get_count () - 1);
}
err = 0;