mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 14:18:37 +00:00
HDB: Fix Crash on Invalid Sound String Pointers
This was causing a crash with buffer overflow on Windows builds, but diagnosing with Valgrind showed invalid strings being accessed in the sound code. Some analysis showed that these were mainly the reference to c_str() buffers from a local heap Common::String which was out of scope and thus destructed, giving an invalid pointer. The fix here also simplifies the code as well as avoiding this issue.
This commit is contained in:
parent
ac3586eb9a
commit
ec677b3fe9
@ -1755,14 +1755,11 @@ void Sound::stopMusic() {
|
||||
}
|
||||
|
||||
void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
|
||||
const char *songName = nullptr;
|
||||
Common::String songName(soundList[song].name);
|
||||
|
||||
if (g_hdb->getPlatform() == Common::kPlatformLinux) {
|
||||
Common::String updatedName(soundList[song].name);
|
||||
updatedName.replace(updatedName.begin() + updatedName.size() - 4, updatedName.end(), ".ogg");
|
||||
songName = updatedName.c_str();
|
||||
} else
|
||||
songName = soundList[song].name;
|
||||
songName.replace(songName.begin() + songName.size() - 4, songName.end(), ".ogg");
|
||||
}
|
||||
|
||||
if (g_hdb->isPPC()) {
|
||||
switch (song) {
|
||||
|
Loading…
Reference in New Issue
Block a user