mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 10:37:38 -04:00
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:
parent
f67dcf0164
commit
9e8045cc80
1 changed files with 12 additions and 2 deletions
|
@ -76,16 +76,26 @@ bool cuesheet_is_enabled(void)
|
||||||
bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path)
|
bool look_for_cuesheet_file(const char *trackpath, char *found_cue_path)
|
||||||
{
|
{
|
||||||
DEBUGF("look for cue file\n");
|
DEBUGF("look for cue file\n");
|
||||||
|
|
||||||
char cuepath[MAX_PATH];
|
char cuepath[MAX_PATH];
|
||||||
|
char *dot, *slash;
|
||||||
|
|
||||||
|
slash = strrchr(trackpath, '/');
|
||||||
|
if (!slash)
|
||||||
|
{
|
||||||
|
found_cue_path = NULL;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
strncpy(cuepath, trackpath, MAX_PATH);
|
strncpy(cuepath, trackpath, MAX_PATH);
|
||||||
char *dot = strrchr(cuepath, '.');
|
dot = strrchr(cuepath, '.');
|
||||||
strcpy(dot, ".cue");
|
strcpy(dot, ".cue");
|
||||||
|
|
||||||
int fd = open(cuepath,O_RDONLY);
|
int fd = open(cuepath,O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
strcpy(cuepath, CUE_DIR);
|
strcpy(cuepath, CUE_DIR);
|
||||||
strcat(cuepath, strrchr(trackpath, '/'));
|
strcat(cuepath, slash);
|
||||||
char *dot = strrchr(cuepath, '.');
|
char *dot = strrchr(cuepath, '.');
|
||||||
strcpy(dot, ".cue");
|
strcpy(dot, ".cue");
|
||||||
fd = open(cuepath,O_RDONLY);
|
fd = open(cuepath,O_RDONLY);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue