Fix: Truncated music-set song names cause warning log.

The music-set does not need to be selected for this to occur.

Resolved by using std::string instead of fixed buffer for song names,
which avoids manual string copying and removes the length limit.
This commit is contained in:
Peter Nelson
2023-01-26 14:58:51 +00:00
committed by PeterN
parent 2d3250923c
commit 1ec34acb51
3 changed files with 4 additions and 6 deletions

View File

@@ -128,7 +128,6 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
for (uint i = 0; i < lengthof(this->songinfo); i++) {
const char *filename = this->files[i].filename;
if (names == nullptr || StrEmpty(filename) || this->files[i].check_result == MD5File::CR_NO_FILE) {
this->songinfo[i].songname[0] = '\0';
continue;
}
@@ -142,10 +141,9 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
char *songname = GetMusicCatEntryName(filename, this->songinfo[i].cat_index);
if (songname == nullptr) {
Debug(grf, 0, "Base music set song missing from CAT file: {}/{}", filename, this->songinfo[i].cat_index);
this->songinfo[i].songname[0] = '\0';
continue;
}
strecpy(this->songinfo[i].songname, songname, lastof(this->songinfo[i].songname));
this->songinfo[i].songname = songname;
free(songname);
} else {
this->songinfo[i].filetype = MTT_STANDARDMIDI;
@@ -166,7 +164,7 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
if (this->songinfo[i].filetype == MTT_STANDARDMIDI) {
if (item != nullptr && item->value.has_value() && !item->value->empty()) {
strecpy(this->songinfo[i].songname, item->value->c_str(), lastof(this->songinfo[i].songname));
this->songinfo[i].songname = item->value.value();
} else {
Debug(grf, 0, "Base music set song name missing: {}", filename);
return false;