NUVIE: Fix Ultima 6 crash on FM-Towns sound load

U6Lib_n::close(): Do not call close() on NuvieIO buffers passed to us
via U6Lib_n::open(). Let the caller handle this instead.

Prevents a crash caused by the following events:

- The game detects the files of the FM-Towns version
   ("townsu6" in the game directory) and eventually attempts to load
   "sounds1.dat" in TownsSfxManager::loadSound1Dat()

- Here, it creates local objects U6Lib_n "lib" and NuvieIOBuffer "iobuf"

- File data is loaded into "iobuf", which is then passed to "lib" via
   pointer. This pointer is stored by "lib"

- When TownsSfxManager::loadSound1Dat() returns, "iobuf" goes out of
   scope and is destroyed before "lib"

- The destructor of "lib" tries to call close() via the stale pointer,
   thus causing the crash

Fixes #14429
This commit is contained in:
PushmePullyu 2023-04-24 08:07:06 +02:00 committed by Eugene Sandulenko
parent 630fe0e8d0
commit c808ad4a8a

View File

@ -73,11 +73,11 @@ void U6Lib_n::close() {
}
items = NULL;
if (data != NULL)
data->close();
if (del_data)
if (del_data) {
if (data != NULL)
data->close();
delete data;
}
data = NULL;
del_data = false;