[Scummvm-git-logs] scummvm branch-2-6 -> 934c209dc6dc873cb4266a8c829f76a03031b2eb

mduggan noreply at scummvm.org
Tue Sep 27 08:51:13 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:
934c209dc6 ULTIMA8: Fix possible crash on autosave


Commit: 934c209dc6dc873cb4266a8c829f76a03031b2eb
    https://github.com/scummvm/scummvm/commit/934c209dc6dc873cb4266a8c829f76a03031b2eb
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2022-09-27T17:51:06+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