aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorChris Warren-Smith2011-08-08 20:57:28 +1000
committerChris Warren-Smith2011-08-21 16:38:18 +1000
commitd6f7e5933657e2e6fcbd1accf9f8a4b77454daec (patch)
tree24ed2265f9eeb7913d6690b35c92ecb7db4bd2d7 /engines/scumm
parentfecce484ce39ddd1d09e8d7a45f6ae22e63f30c0 (diff)
downloadscummvm-rg350-d6f7e5933657e2e6fcbd1accf9f8a4b77454daec.tar.gz
scummvm-rg350-d6f7e5933657e2e6fcbd1accf9f8a4b77454daec.tar.bz2
scummvm-rg350-d6f7e5933657e2e6fcbd1accf9f8a4b77454daec.zip
BADA: Avoid calling malloc with new_size=0
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/smush/channel.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/engines/scumm/smush/channel.cpp b/engines/scumm/smush/channel.cpp
index 7f71d0549b..f5e0747ba8 100644
--- a/engines/scumm/smush/channel.cpp
+++ b/engines/scumm/smush/channel.cpp
@@ -94,14 +94,16 @@ void SmushChannel::processBuffer() {
_tbufferSize = 0;
} else {
if (offset) {
- byte *old = _tbuffer;
int32 new_size = _tbufferSize - offset;
- _tbuffer = (byte *)malloc(new_size);
- if (!_tbuffer)
- error("smush channel failed to allocate memory");
- memcpy(_tbuffer, old + offset, new_size);
- _tbufferSize = new_size;
- free(old);
+ if (new_size) {
+ byte *old = _tbuffer;
+ _tbuffer = (byte *)malloc(new_size);
+ if (!_tbuffer)
+ error("smush channel failed to allocate memory");
+ memcpy(_tbuffer, old + offset, new_size);
+ _tbufferSize = new_size;
+ free(old);
+ }
}
}
}