diff options
author | orbea | 2019-01-21 07:45:17 -0800 |
---|---|---|
committer | orbea | 2019-01-27 07:22:15 -0800 |
commit | 6f4557bf81c4d12d3a7aaf2b75a355e380a51490 (patch) | |
tree | cc91b8115c5f5ab2853f287c152f0a172d139284 /libpcsxcore | |
parent | c8e850f3584ba1eea367373d76d8b768a58d6d2c (diff) | |
download | pcsx_rearmed-6f4557bf81c4d12d3a7aaf2b75a355e380a51490.tar.gz pcsx_rearmed-6f4557bf81c4d12d3a7aaf2b75a355e380a51490.tar.bz2 pcsx_rearmed-6f4557bf81c4d12d3a7aaf2b75a355e380a51490.zip |
Fix segfault when loading cue files from relative paths.
Fixes https://github.com/libretro/pcsx_rearmed/issues/63
Diffstat (limited to 'libpcsxcore')
-rw-r--r-- | libpcsxcore/cdriso.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index 169c945..cf1a59e 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -565,20 +565,15 @@ static int parsecue(const char *isofile) { if (t != 1) sscanf(linebuf, " FILE %255s", tmpb); - // absolute path? - ti[numtracks + 1].handle = fopen(tmpb, "rb"); - if (ti[numtracks + 1].handle == NULL) { - // relative to .cue? - tmp = strrchr(tmpb, '\\'); - if (tmp == NULL) - tmp = strrchr(tmpb, '/'); - if (tmp != NULL) - tmp++; - else - tmp = tmpb; - strncpy(incue_fname, tmp, incue_max_len); - ti[numtracks + 1].handle = fopen(filepath, "rb"); - } + tmp = strrchr(tmpb, '\\'); + if (tmp == NULL) + tmp = strrchr(tmpb, '/'); + if (tmp != NULL) + tmp++; + else + tmp = tmpb; + strncpy(incue_fname, tmp, incue_max_len); + ti[numtracks + 1].handle = fopen(filepath, "rb"); // update global offset if this is not first file in this .cue if (numtracks + 1 > 1) { |