From b3f845a60d1f5930180599e718f8ad07761a9810 Mon Sep 17 00:00:00 2001 From: moritz Date: Fri, 14 Sep 2007 06:59:28 +0000 Subject: [PATCH] If there are no playlist entries, dereferencing pl->list causes a segfault. Fix this by checking pl->num early. git-svn-id: https://svn.xiph.org/trunk/ezstream@13800 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- src/playlist.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/playlist.c b/src/playlist.c index 1dc05da..f0d1df0 100644 --- a/src/playlist.c +++ b/src/playlist.c @@ -287,6 +287,9 @@ playlist_get_next(playlist_t *pl) if (pl->program) return (playlist_run_program(pl)); + if (pl->num == 0) + return (NULL); + return ((const char *)pl->list[pl->index++]); } @@ -299,7 +302,7 @@ playlist_peek_next(playlist_t *pl) exit(1); } - if (pl->program) + if (pl->program || pl->num == 0) return (NULL); return ((const char *)pl->list[pl->index]); @@ -314,7 +317,7 @@ playlist_skip_next(playlist_t *pl) exit(1); } - if (pl->program) + if (pl->program || pl->num == 0) return; if (pl->list[pl->index] != NULL)