[Scummvm-git-logs] scummvm master -> 628f008e6d956fdd7a66ef09278d4c94174e5733

mduggan noreply at scummvm.org
Tue Sep 27 08:50:40 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
628f008e6d ULTIMA8: Fix possible crash on autosave


Commit: 628f008e6d956fdd7a66ef09278d4c94174e5733
    https://github.com/scummvm/scummvm/commit/628f008e6d956fdd7a66ef09278d4c94174e5733
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2022-09-27T17:47:46+09:00

Commit Message:
ULTIMA8: Fix possible crash on autosave

Because autosave can be triggered at any time, there may be empty lists present
in the engine.  Avoid crashing if the UCList is empty.  Should fix bug #13852.

Changed paths:
    engines/ultima/ultima8/usecode/uc_list.cpp


diff --git a/engines/ultima/ultima8/usecode/uc_list.cpp b/engines/ultima/ultima8/usecode/uc_list.cpp
index ce0e840711e..4c5e1ba3384 100644
--- a/engines/ultima/ultima8/usecode/uc_list.cpp
+++ b/engines/ultima/ultima8/usecode/uc_list.cpp
@@ -116,7 +116,8 @@ void UCList::removeString(uint16 s, bool nodel) {
 void UCList::save(Common::WriteStream *ws) const {
 	ws->writeUint32LE(_elementSize);
 	ws->writeUint32LE(_size);
-	ws->write(&(_elements[0]), _size * _elementSize);
+	if (_size > 0)
+		ws->write(&(_elements[0]), _size * _elementSize);
 }
 
 
@@ -128,7 +129,8 @@ bool UCList::load(Common::ReadStream *rs, uint32 version) {
 		return false;
 	}
 	_elements.resize(_size * _elementSize);
-	rs->read(&(_elements[0]), _size * _elementSize);
+	if (_size > 0)
+		rs->read(&(_elements[0]), _size * _elementSize);
 
 	return true;
 }




More information about the Scummvm-git-logs mailing list