aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreriktorbjorn2011-06-17 05:56:23 +0200
committereriktorbjorn2011-06-17 05:56:23 +0200
commitabf26b0614581f2725f65621d0403255884a9cc2 (patch)
tree4810317eb75df62e5371a6bd3c44d86f8109bc6c
parentf090eb672714233eea7f13dd56c2fd159fd6bd7e (diff)
downloadscummvm-rg350-abf26b0614581f2725f65621d0403255884a9cc2.tar.gz
scummvm-rg350-abf26b0614581f2725f65621d0403255884a9cc2.tar.bz2
scummvm-rg350-abf26b0614581f2725f65621d0403255884a9cc2.zip
GRAPHICS: Fix Valgrind warning
The stream class uses free() to automatically dispose of the buffer so it must be allocated with malloc(), not "new".
-rw-r--r--graphics/png.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/graphics/png.cpp b/graphics/png.cpp
index c250433222..a1cf266227 100644
--- a/graphics/png.cpp
+++ b/graphics/png.cpp
@@ -236,7 +236,7 @@ bool PNG::read(Common::SeekableReadStream *str) {
case kChunkIDAT:
if (_compressedBufferSize == 0) {
_compressedBufferSize += chunkLength;
- _compressedBuffer = new byte[_compressedBufferSize];
+ _compressedBuffer = (byte *)malloc(_compressedBufferSize);
_stream->read(_compressedBuffer, chunkLength);
} else {
// Expand the buffer
@@ -244,8 +244,8 @@ bool PNG::read(Common::SeekableReadStream *str) {
_compressedBufferSize += chunkLength;
byte *tmp = new byte[prevSize];
memcpy(tmp, _compressedBuffer, prevSize);
- delete[] _compressedBuffer;
- _compressedBuffer = new byte[_compressedBufferSize];
+ free(_compressedBuffer);
+ _compressedBuffer = (byte *)malloc(_compressedBufferSize);
memcpy(_compressedBuffer, tmp, prevSize);
delete[] tmp;
_stream->read(_compressedBuffer + prevSize, chunkLength);