Don't underflow the buffer in format_track_path() if it consists of whitespaces

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29325 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Jarosch 2011-02-18 21:39:59 +00:00
parent 84fccff170
commit 15a5f9ca95

View file

@ -1666,12 +1666,13 @@ static int format_track_path(char *dest, char *src, int buf_length, int max,
i++;
/* Now work back killing white space */
while((src[i-1] == ' ') ||
(src[i-1] == '\t'))
while((i > 0) &&
((src[i-1] == ' ') ||
(src[i-1] == '\t')))
i--;
src[i]=0;
/* replace backslashes with forward slashes */
for ( j=0; j<i; j++ )
if ( src[j] == '\\' )