summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/music/midifile.cpp14
1 files changed, 8 insertions, 6 deletions
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';