Fix a possible crash in the cuesheet code if the filename lacks a slash, which happens for some reason I don't quite understand yet.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16229 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Nicolas Pennequin 2008-02-05 20:00:14 +00:00
parent f67dcf0164
commit 9e8045cc80

View file

@ -76,16 +76,26 @@ bool cuesheet_is_enabled(void)
bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path)
{
DEBUGF("look for cue file\n");
char cuepath[MAX_PATH];
char *dot, *slash;
slash = strrchr(trackpath, '/');
if (!slash)
{
found_cue_path = NULL;
return false;
}
strncpy(cuepath, trackpath, MAX_PATH);
char *dot = strrchr(cuepath, '.');
dot = strrchr(cuepath, '.');
strcpy(dot, ".cue");
int fd = open(cuepath,O_RDONLY);
if (fd < 0)
{
strcpy(cuepath, CUE_DIR);
strcat(cuepath, strrchr(trackpath, '/'));
strcat(cuepath, slash);
char *dot = strrchr(cuepath, '.');
strcpy(dot, ".cue");
fd = open(cuepath,O_RDONLY);