[Scummvm-git-logs] scummvm master -> 89c67944f4c0d51c1fc6f81c2bbc3c78ca862812

sluicebox 22204938+sluicebox at users.noreply.github.com
Tue Feb 2 20:45:23 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:
89c67944f4 SCI: Always initialize kFileIOReadString output


Commit: 89c67944f4c0d51c1fc6f81c2bbc3c78ca862812
    https://github.com/scummvm/scummvm/commit/89c67944f4c0d51c1fc6f81c2bbc3c78ca862812
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2021-02-02T12:44:45-08:00

Commit Message:
SCI: Always initialize kFileIOReadString output

Addresses bug #12060

Changed paths:
    engines/sci/engine/file.cpp


diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp
index 62bcac58f1..c558634bbc 100644
--- a/engines/sci/engine/file.cpp
+++ b/engines/sci/engine/file.cpp
@@ -268,6 +268,10 @@ FileHandle *getFileFromHandle(EngineState *s, uint handle) {
 }
 
 int fgets_wrapper(EngineState *s, char *dest, int maxsize, int handle) {
+	// always initialize because some scripts don't test for errors and
+	//  just use the results, even from invalid file handles. bug #12060 
+	memset(dest, 0, maxsize);
+
 	FileHandle *f = getFileFromHandle(s, handle);
 	if (!f)
 		return 0;
@@ -278,7 +282,6 @@ int fgets_wrapper(EngineState *s, char *dest, int maxsize, int handle) {
 	}
 	int readBytes = 0;
 	if (maxsize > 1) {
-		memset(dest, 0, maxsize);
 		f->_in->readLine(dest, maxsize);
 		readBytes = Common::strnlen(dest, maxsize); // FIXME: sierra sci returned byte count and didn't react on NUL characters
 		// The returned string must not have an ending LF




More information about the Scummvm-git-logs mailing list