[Scummvm-git-logs] scummvm master -> 424eb6d7a70ec16fa9a6e6c938938cf77b0cc3cb

athrxx noreply at scummvm.org
Tue Sep 20 22:17:02 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:
424eb6d7a7 KYRA: (DOS/Floppy) - add some sanity checks/errors


Commit: 424eb6d7a70ec16fa9a6e6c938938cf77b0cc3cb
    https://github.com/scummvm/scummvm/commit/424eb6d7a70ec16fa9a6e6c938938cf77b0cc3cb
Author: athrxx (athrxx at scummvm.org)
Date: 2022-09-21T00:16:48+02:00

Commit Message:
KYRA: (DOS/Floppy) - add some sanity checks/errors

(these never get triggered, but this isn't obvious, neither to static checkers nor to human beings)

Changed paths:
    engines/kyra/resource/resource_intern.cpp


diff --git a/engines/kyra/resource/resource_intern.cpp b/engines/kyra/resource/resource_intern.cpp
index 8da04970931..c38ca3f381d 100644
--- a/engines/kyra/resource/resource_intern.cpp
+++ b/engines/kyra/resource/resource_intern.cpp
@@ -1088,6 +1088,9 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
 						newEntry.name = entryStr;
 					}
 
+					// The pointer (and the responsibility for the deletion) has been
+					// passed on. Clear the variable as a signal that it can be reused.
+					outbuffer = nullptr;
 					fileList.push_back(newEntry);
 				}
 				pos++;
@@ -1136,6 +1139,12 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
 					pos += (kHeaderSize + filestrlen - m);
 					tmpFile->seek(pos, SEEK_SET);
 
+					if (outbuffer) {
+						delete[] outbuffer;
+						// We can prevent memory leakage, but we should never arrive here, since we still have unprocessed data in the outbuffer.
+						error("InstallerLoader::load(): Unknown decompression failure.");
+					}
+
 					outbuffer = new uint8[outsize];
 					if (!outbuffer)
 						error("Out of memory: Can't uncompress installer files");
@@ -1177,6 +1186,7 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
 							newEntry.name = entryStr;
 						}
 
+						outbuffer = nullptr;
 						fileList.push_back(newEntry);
 					}
 
@@ -1195,6 +1205,12 @@ Common::Archive *InstallerLoader::load(Resource *owner, const Common::String &fi
 		}
 	}
 
+	if (outbuffer) {
+		delete[] outbuffer;
+		// We can prevent memory leakage, but we should never arrive here, since we still have unprocessed data in the outbuffer.
+		error("InstallerLoader::load(): Unknown decompression failure.");
+	}
+
 	archives.clear();
 	return new CachedArchive(fileList);
 }




More information about the Scummvm-git-logs mailing list