summaryrefslogtreecommitdiff
path: root/playlist.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2012-04-25 17:23:03 +0200
committerGravatar waker <wakeroid@gmail.com>2012-04-25 17:23:03 +0200
commitce7f7611615bbe32c859a94a13f343097a120f19 (patch)
tree028bac1bf2348343dec8f1a55a16119b685104b2 /playlist.c
parent1f2971ba366fea13936ff6bd18dfc47906cc314e (diff)
fixed plt_search_process bug which was creating single-linked list instead of double-linked;
fixed plt_load bug which was leading to crash if playlist file fails to load early, e.g. if a file has size of 0
Diffstat (limited to 'playlist.c')
-rw-r--r--playlist.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/playlist.c b/playlist.c
index 2c07fccf..cc8eca64 100644
--- a/playlist.c
+++ b/playlist.c
@@ -2134,12 +2134,14 @@ plt_load (playlist_t *plt, playItem_t *after, const char *fname, int *pabort, in
return NULL;
}
+ playItem_t *last_added = NULL;
uint8_t majorver;
uint8_t minorver;
playItem_t *it = NULL;
char magic[4];
if (fread (magic, 1, 4, fp) != 4) {
+ trace ("failed to read magic\n");
goto load_fail;
}
if (strncmp (magic, "DBPL", 4)) {
@@ -2166,8 +2168,6 @@ plt_load (playlist_t *plt, playItem_t *after, const char *fname, int *pabort, in
goto load_fail;
}
- playItem_t *last_added = NULL;
-
for (uint32_t i = 0; i < cnt; i++) {
it = pl_item_alloc ();
if (!it) {
@@ -2379,6 +2379,7 @@ plt_load (playlist_t *plt, playItem_t *after, const char *fname, int *pabort, in
trace ("plt_load: success\n");
return last_added;
load_fail:
+ plt_clear (plt);
fprintf (stderr, "playlist load fail (%s)!\n", fname);
if (fp) {
fclose (fp);
@@ -3551,6 +3552,7 @@ plt_search_process (playlist_t *playlist, const char *text) {
if (abs (cmp) == cmpidx) {
if (cmp > 0) {
it->next[PL_SEARCH] = NULL;
+ it->prev[PL_SEARCH] = playlist->tail[PL_SEARCH];
if (playlist->tail[PL_SEARCH]) {
playlist->tail[PL_SEARCH]->next[PL_SEARCH] = it;
playlist->tail[PL_SEARCH] = it;
@@ -3567,6 +3569,7 @@ plt_search_process (playlist_t *playlist, const char *text) {
//fprintf (stderr, "%s -> %s match (%s.%s)\n", text, m->value, pl_find_meta_raw (it, ":URI"), m->key);
// add to list
it->next[PL_SEARCH] = NULL;
+ it->prev[PL_SEARCH] = playlist->tail[PL_SEARCH];
if (playlist->tail[PL_SEARCH]) {
playlist->tail[PL_SEARCH]->next[PL_SEARCH] = it;
playlist->tail[PL_SEARCH] = it;