From bb086f92403aa70d5756c334df31a65f4b854e39 Mon Sep 17 00:00:00 2001 From: Niels Martin Hansen Date: Mon, 3 Sep 2018 18:43:55 +0200 Subject: Fix: Better "temp" path for decoded MPSMIDI files when source filename has no path separators --- src/music/midifile.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/music') diff --git a/src/music/midifile.cpp b/src/music/midifile.cpp index 9506776ef..931be181a 100644 --- a/src/music/midifile.cpp +++ b/src/music/midifile.cpp @@ -1020,16 +1020,18 @@ std::string MidiFile::GetSMFFile(const MusicSongInfo &song) if (song.filetype != MTT_MPSMIDI) return std::string(); - const char *lastpathsep = strrchr(song.filename, PATHSEPCHAR); - if (lastpathsep == NULL) { - lastpathsep = song.filename; - } - char basename[MAX_PATH]; { + const char *fnstart = strrchr(song.filename, PATHSEPCHAR); + if (fnstart == NULL) { + fnstart = song.filename; + } else { + fnstart++; + } + /* Remove all '.' characters from filename */ char *wp = basename; - for (const char *rp = lastpathsep + 1; *rp != '\0'; rp++) { + for (const char *rp = fnstart; *rp != '\0'; rp++) { if (*rp != '.') *wp++ = *rp; } *wp++ = '\0'; -- cgit v1.2.3-54-g00ecf