Commit c9e6201d authored by Max Kellermann's avatar Max Kellermann Committed by Eric Wong

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/trunk@7200 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent c5b524e3
......@@ -272,7 +272,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, NULL)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment