From c0e0c2460f19f750d7fb74f1f74d395c5a5c222c Mon Sep 17 00:00:00 2001
From: Warren Dukes <warren.dukes@gmail.com>
Date: Fri, 15 Oct 2004 18:27:29 +0000
Subject: fix bug #307

git-svn-id: https://svn.musicpd.org/mpd/trunk@2230 09075e82-0dd4-0310-85a5-a0d7c8717e4f
---
 src/playlist.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'src/playlist.c')

diff --git a/src/playlist.c b/src/playlist.c
index 1eba3b7be..c7e5057db 100644
--- a/src/playlist.c
+++ b/src/playlist.c
@@ -1318,7 +1318,7 @@ int savePlaylist(FILE * fp, char * utf8file) {
 
 int loadPlaylist(FILE * fp, char * utf8file) {
 	FILE * fileP;
-	char s[MAXPATHLEN*1];
+	char s[MAXPATHLEN+1];
 	int slength = 0;
 	char * temp = strdup(utf8ToFsCharset(utf8file));
 	char * rfile = malloc(strlen(temp)+strlen(".")+
@@ -1328,6 +1328,7 @@ int loadPlaylist(FILE * fp, char * utf8file) {
 	int parentlen = strlen(parent);
 	char * erroredFile = NULL;
 	int tempInt;
+	int commentCharFound = 0;
 
 	strcpy(rfile,temp);
 	strcat(rfile,".");
@@ -1353,7 +1354,11 @@ int loadPlaylist(FILE * fp, char * utf8file) {
 	while((tempInt = fgetc(fileP))!=EOF) {
 		s[slength] = tempInt;
 		if(s[slength]=='\n' || s[slength]=='\0') {
+			commentCharFound = 0;
 			s[slength] = '\0';
+			if(s[0]==PLAYLIST_COMMENT) {
+				commentCharFound = 1;
+			}
 			if(strncmp(s,musicDir,strlen(musicDir))==0) {
 				strcpy(s,&(s[strlen(musicDir)]));
 			}
@@ -1379,7 +1384,7 @@ int loadPlaylist(FILE * fp, char * utf8file) {
 			temp = fsCharsetToUtf8(s);
 			if(!temp) continue;
 			temp = strdup(temp);
-			if(s[0]==PLAYLIST_COMMENT && !getSongFromDB(temp)
+			if(commentCharFound && !getSongFromDB(temp)
 					&& !isRemoteUrl(temp)) 
 			{
 				free(temp);
-- 
cgit v1.2.3