mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-02 15:16:46 +00:00
GRAPHICS: Fix Valgrind warning
The stream class uses free() to automatically dispose of the buffer so it must be allocated with malloc(), not "new".
This commit is contained in:
parent
f090eb6727
commit
abf26b0614
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user