aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-06-14 04:16:16 +0000
committerEric Wong <normalperson@yhbt.net>2008-06-14 04:16:16 +0000
commit0c2b12f0985632f5d93e1053708d23290baef698 (patch)
tree4d69bdad918b84e948a3766d00711a0a36e81088 /src
parentc55b9706f6b8c04864570e743c5fe7191e1ee0ad (diff)
downloadmpd-0c2b12f0985632f5d93e1053708d23290baef698.tar.gz
mpd-0c2b12f0985632f5d93e1053708d23290baef698.tar.xz
mpd-0c2b12f0985632f5d93e1053708d23290baef698.zip
fix strtok() related segmentation fault
strtok() may return NULL if the input is an empty string. The playlist parser did not check for that. git-svn-id: https://svn.musicpd.org/mpd/branches/branch-0.13.0-fixes@7378 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/playlist.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/playlist.c b/src/playlist.c
index 56915a487..7bb66f55f 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -275,7 +275,10 @@ static void loadPlaylistFromStateFile(FILE *fp, char *buffer,
if (!myFgets(buffer, PLAYLIST_BUFFER_SIZE, fp))
state_file_fatal();
while (strcmp(buffer, PLAYLIST_STATE_FILE_PLAYLIST_END)) {
- song = atoi(strtok(buffer, ":"));
+ temp = strtok(buffer, ":");
+ if (temp == NULL)
+ state_file_fatal();
+ song = atoi(temp);
if (!(temp = strtok(NULL, "")))
state_file_fatal();
if (!addToPlaylist(STDERR_FILENO, temp, 0) && current == song) {