From 0c2b12f0985632f5d93e1053708d23290baef698 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 14 Jun 2008 04:16:16 +0000 Subject: 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 --- src/playlist.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') 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) { -- cgit v1.2.3