[Scummvm-git-logs] scummvm master -> e42950e27bf196c61fa9cc02e03430f3284b7168
neuromancer
noreply at scummvm.org
Wed Jan 26 10:19:04 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:
e42950e27b HYPNO: fixed memory leak and improved code performance in fixSmackerHeader
Commit: e42950e27bf196c61fa9cc02e03430f3284b7168
https://github.com/scummvm/scummvm/commit/e42950e27bf196c61fa9cc02e03430f3284b7168
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2022-01-26T11:19:05+01:00
Commit Message:
HYPNO: fixed memory leak and improved code performance in fixSmackerHeader
Changed paths:
engines/hypno/hypno.cpp
diff --git a/engines/hypno/hypno.cpp b/engines/hypno/hypno.cpp
index 07609304968..4ee220cddd2 100644
--- a/engines/hypno/hypno.cpp
+++ b/engines/hypno/hypno.cpp
@@ -299,17 +299,16 @@ Common::File *HypnoEngine::fixSmackerHeader(Common::File *file) {
magic += file->readByte();
if (magic == "HYP2") {
- ByteArray *data = new ByteArray();
- data->push_back('S');
- data->push_back('M');
- data->push_back('K');
- data->push_back('2');
- while (!file->eos()) {
- data->push_back(file->readByte());
- }
+ uint32 size = file->size();
+ byte *data = (byte *)malloc(size);
+ file->seek(0);
+ file->read(data, size);
+ data[0] = 'S';
+ data[1] = 'M';
+ data[2] = 'K';
file->close();
delete file;
- file = (Common::File *) new Common::MemoryReadStream(data->data(), data->size());
+ file = (Common::File *) new Common::MemoryReadStream(data, size, DisposeAfterUse::YES);
} else
file->seek(0);
More information about the Scummvm-git-logs
mailing list