playlist: Fix a null pointer dereference in init()
This happens if we try to use the Banned playlist before it exists in the database. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
43c8130ecc
commit
00ff9cd08f
|
@ -42,6 +42,9 @@ void playlist :: init()
|
|||
playlist_db.load();
|
||||
|
||||
IndexEntry *ent = get_tracks("Banned");
|
||||
if (!ent)
|
||||
return;
|
||||
|
||||
for (it = ent->values.begin(); it != ent->values.end(); it++)
|
||||
library :: get_queue()->del(tagdb :: lookup(*it));
|
||||
}
|
||||
|
|
|
@ -153,6 +153,8 @@ static void test_next_prev()
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test :: rm_data_dir();
|
||||
|
||||
run_test("Deck Init Test", test_init);
|
||||
run_test("Deck Create, Move and Destroy Test", test_create_mv_destroy);
|
||||
run_test("Deck Next and Prev Test", test_next_prev);
|
||||
|
|
|
@ -18,6 +18,10 @@ static void test_init()
|
|||
test_equal(q->has_flag(Q_REPEAT), true);
|
||||
test_equal(q->has_flag(Q_NO_SORT), true);
|
||||
|
||||
/* init should work even if playlist.db doesn't exist! */
|
||||
playlist :: init();
|
||||
|
||||
test :: cp_data_dir();
|
||||
tagdb :: init();
|
||||
library :: init();
|
||||
playlist :: init();
|
||||
|
@ -110,7 +114,7 @@ static void test_has()
|
|||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test :: cp_data_dir();
|
||||
test :: rm_data_dir();
|
||||
|
||||
run_test("Playlist Initialization Test", test_init);
|
||||
run_test("Playlist Queue Test", test_queue);
|
||||
|
|
Loading…
Reference in New Issue