From d6f7e5933657e2e6fcbd1accf9f8a4b77454daec Mon Sep 17 00:00:00 2001 From: Chris Warren-Smith Date: Mon, 8 Aug 2011 20:57:28 +1000 Subject: BADA: Avoid calling malloc with new_size=0 --- engines/scumm/smush/channel.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'engines/scumm') 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); + } } } } -- cgit v1.2.3