m3u playlist parser: Check size limit before using buffer

This should only be a problem if the last line
is not terminated by \r or \n though.

cppcheck reported:
[rockbox/apps/playlist.c:234]: (style) Array index 'i' is used before limits check.

Change-Id: I8182b66272ba9c024984c81588bd2a6dbb8255b8
This commit is contained in:
Thomas Jarosch 2014-12-20 13:09:22 +01:00
parent 2caf8870af
commit f8d9e9cb6c

View file

@ -231,7 +231,7 @@ static int convert_m3u(char* buf, int buf_len, int buf_max, char* temp)
char* dest;
/* Locate EOL. */
while ((buf[i] != '\n') && (buf[i] != '\r') && (i < buf_len))
while ((i < buf_len) && (buf[i] != '\n') && (buf[i] != '\r'))
{
i++;
}