[Scummvm-cvs-logs] SF.net SVN: scummvm:[43918] scummvm/trunk
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Thu Sep 3 18:15:10 CEST 2009
Revision: 43918
http://scummvm.svn.sourceforge.net/scummvm/?rev=43918&view=rev
Author: mthreepwood
Date: 2009-09-03 16:15:10 +0000 (Thu, 03 Sep 2009)
Log Message:
-----------
Fix a new/free mismatch when creating a MemoryReadStream from a MemoryWriteStreamDynamic by changing MemoryWriteStreamDynamic to use malloc/free instead of new/delete[]. This could have affected ScummEngine_v4::prepareSavegame().
Modified Paths:
--------------
scummvm/trunk/common/stream.h
scummvm/trunk/engines/m4/midi.cpp
Modified: scummvm/trunk/common/stream.h
===================================================================
--- scummvm/trunk/common/stream.h 2009-09-03 14:27:23 UTC (rev 43917)
+++ scummvm/trunk/common/stream.h 2009-09-03 16:15:10 UTC (rev 43918)
@@ -649,13 +649,13 @@
byte *old_data = _data;
_capacity = new_len + 32;
- _data = new byte[_capacity];
+ _data = (byte *)malloc(_capacity);
_ptr = _data + _pos;
if (old_data) {
// Copy old data
memcpy(_data, old_data, _size);
- delete[] old_data;
+ free(old_data);
}
_size = new_len;
@@ -665,7 +665,7 @@
~MemoryWriteStreamDynamic() {
if (_disposeMemory)
- delete[] _data;
+ free(_data);
}
uint32 write(const void *dataPtr, uint32 dataSize) {
Modified: scummvm/trunk/engines/m4/midi.cpp
===================================================================
--- scummvm/trunk/engines/m4/midi.cpp 2009-09-03 14:27:23 UTC (rev 43917)
+++ scummvm/trunk/engines/m4/midi.cpp 2009-09-03 16:15:10 UTC (rev 43918)
@@ -47,7 +47,9 @@
stopMusic();
close();
delete _parser;
- delete _midiData;
+
+ if (_midiData)
+ free(_midiData);
}
void MidiPlayer::setVolume(int volume) {
@@ -181,8 +183,11 @@
if (_parser) {
_parser->unloadMusic();
}
- delete[] _midiData;
- _midiData = NULL;
+
+ if (_midiData) {
+ free(_midiData);
+ _midiData = NULL;
+ }
}
// This function will convert HMP music into type 1 SMF, which our SMF parser
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list