From: orbea Date: Mon, 21 Jan 2019 15:45:17 +0000 (-0800) Subject: Fix segfault when loading cue files from relative paths. X-Git-Tag: r24l~757^2 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f4557bf81c4d12d3a7aaf2b75a355e380a51490;p=pcsx_rearmed.git Fix segfault when loading cue files from relative paths. Fixes https://github.com/libretro/pcsx_rearmed/issues/63 --- diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index 169c9450..cf1a59e2 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) {