[Scummvm-git-logs] scummvm master -> 9987cc4c5b8ec5c1fedada078d5c2367342553e8

sluicebox 22204938+sluicebox at users.noreply.github.com
Tue Jun 29 18:39:07 UTC 2021


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:
9987cc4c5b BACKENDS: Fix undefined parsing of timestamps file


Commit: 9987cc4c5b8ec5c1fedada078d5c2367342553e8
    https://github.com/scummvm/scummvm/commit/9987cc4c5b8ec5c1fedada078d5c2367342553e8
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2021-06-29T13:37:51-05:00

Commit Message:
BACKENDS: Fix undefined parsing of timestamps file

DefaultSaveFileManager::loadTimestamps() was parsing strings from the
timestamps file by checking for end-of-stream after using the byte it
attempted to read. This worked because ReadStream::readByte() returns 0
on error, but that's undefined behavior with a FIXME to remove.

This bug was exposed by the recently added warning when 0 is appended
to a String: ab06f27d4349741945c3d0763a717c118a9e1cbc

Changed paths:
    backends/saves/default/default-saves.cpp


diff --git a/backends/saves/default/default-saves.cpp b/backends/saves/default/default-saves.cpp
index b93cd22185..50c4aa6851 100644
--- a/backends/saves/default/default-saves.cpp
+++ b/backends/saves/default/default-saves.cpp
@@ -309,8 +309,9 @@ Common::HashMap<Common::String, uint32> DefaultSaveFileManager::loadTimestamps()
 	while (!file->eos()) {
 		//read filename into buffer (reading until the first ' ')
 		Common::String buffer;
-		while (!file->eos()) {
+		while (true) {
 			byte b = file->readByte();
+			if (file->eos()) break;
 			if (b == ' ') break;
 			buffer += (char)b;
 		}
@@ -320,8 +321,9 @@ Common::HashMap<Common::String, uint32> DefaultSaveFileManager::loadTimestamps()
 		while (true) {
 			bool lineEnded = false;
 			buffer = "";
-			while (!file->eos()) {
+			while (true) {
 				byte b = file->readByte();
+				if (file->eos()) break;
 				if (b == ' ' || b == '\n' || b == '\r') {
 					lineEnded = (b == '\n');
 					break;




More information about the Scummvm-git-logs mailing list