[Scummvm-cvs-logs] scummvm master -> bc4691a23e0ff1ff6f2452d7ad5d4cd612ad06a1
wjp
wjp at usecode.org
Sat Jun 25 21:20:58 CEST 2011
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:
bc4691a23e SCI: Fix incorrect usage of sizeof
Commit: bc4691a23e0ff1ff6f2452d7ad5d4cd612ad06a1
https://github.com/scummvm/scummvm/commit/bc4691a23e0ff1ff6f2452d7ad5d4cd612ad06a1
Author: Willem Jan Palenstijn (wjp at usecode.org)
Date: 2011-06-25T12:16:12-07:00
Commit Message:
SCI: Fix incorrect usage of sizeof
Thanks to salty-horse for the reports.
Changed paths:
engines/sci/decompressor.cpp
engines/sci/engine/vm.cpp
diff --git a/engines/sci/decompressor.cpp b/engines/sci/decompressor.cpp
index 7e7acab..82af6ec 100644
--- a/engines/sci/decompressor.cpp
+++ b/engines/sci/decompressor.cpp
@@ -257,7 +257,8 @@ int DecompressorLZW::unpackLZW1(Common::ReadStream *src, byte *dest, uint32 nPac
init(src, dest, nPacked, nUnpacked);
byte *stak = (byte *)malloc(0x1014);
- Tokenlist *tokens = (Tokenlist *)malloc(0x1004 * sizeof(Tokenlist));
+ unsigned int tokensSize = 0x1004 * sizeof(Tokenlist);
+ Tokenlist *tokens = (Tokenlist *)malloc(tokensSize);
if (!stak || !tokens) {
free(stak);
free(tokens);
@@ -265,7 +266,7 @@ int DecompressorLZW::unpackLZW1(Common::ReadStream *src, byte *dest, uint32 nPac
error("[DecompressorLZW::unpackLZW1] Cannot allocate decompression buffers");
}
- memset(tokens, 0, sizeof(tokens));
+ memset(tokens, 0, tokensSize);
byte lastchar = 0;
uint16 stakptr = 0, lastbits = 0;
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index db682de..274b0bb 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -462,7 +462,7 @@ int readPMachineInstruction(const byte *src, byte &extOpcode, int16 opparams[4])
extOpcode = src[offset++]; // Get "extended" opcode (lower bit has special meaning)
const byte opcode = extOpcode >> 1; // get the actual opcode
- memset(opparams, 0, sizeof(opparams));
+ memset(opparams, 0, 4*sizeof(int16));
for (int i = 0; g_opcode_formats[opcode][i]; ++i) {
//debugN("Opcode: 0x%x, Opnumber: 0x%x, temp: %d\n", opcode, opcode, temp);
More information about the Scummvm-git-logs
mailing list