[Scummvm-cvs-logs] SF.net SVN: scummvm:[48832] scummvm/trunk/engines/scumm/player_v2a.cpp
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Apr 28 22:18:56 CEST 2010
Revision: 48832
http://scummvm.svn.sourceforge.net/scummvm/?rev=48832&view=rev
Author: fingolfin
Date: 2010-04-28 20:18:56 +0000 (Wed, 28 Apr 2010)
Log Message:
-----------
Fix for bug #2824840: ZAK: Crash when using the yellow crystal (Amiga version)
The problem was a double free that could occur in two places.
Also added some missing whitespaces.
Modified Paths:
--------------
scummvm/trunk/engines/scumm/player_v2a.cpp
Modified: scummvm/trunk/engines/scumm/player_v2a.cpp
===================================================================
--- scummvm/trunk/engines/scumm/player_v2a.cpp 2010-04-28 19:50:28 UTC (rev 48831)
+++ scummvm/trunk/engines/scumm/player_v2a.cpp 2010-04-28 20:18:56 UTC (rev 48832)
@@ -1050,10 +1050,10 @@
memcpy(tmp_data2, data + _offset, _size);
memcpy(tmp_data3, data + _offset, _size);
memcpy(tmp_data4, data + _offset, _size);
- _mod->startChannel(_id | 0x000, tmp_data1, _size, BASE_FREQUENCY / _freq1, MIN((_vol >> 1) + 3,0x32), 0, _size, -127);
- _mod->startChannel(_id | 0x100, tmp_data2, _size, BASE_FREQUENCY / _freq2, MIN((_vol >> 1) + 3,0x32), 0, _size, 127);
- _mod->startChannel(_id | 0x200, tmp_data3, _size, BASE_FREQUENCY / _freq3, MIN((_vol >> 1) + 3,0x32), 0, _size, 127);
- _mod->startChannel(_id | 0x300, tmp_data4, _size, BASE_FREQUENCY / _freq4, MIN((_vol >> 1) + 3,0x32), 0, _size, -127);
+ _mod->startChannel(_id | 0x000, tmp_data1, _size, BASE_FREQUENCY / _freq1, MIN((_vol >> 1) + 3, 0x32), 0, _size, -127);
+ _mod->startChannel(_id | 0x100, tmp_data2, _size, BASE_FREQUENCY / _freq2, MIN((_vol >> 1) + 3, 0x32), 0, _size, 127);
+ _mod->startChannel(_id | 0x200, tmp_data3, _size, BASE_FREQUENCY / _freq3, MIN((_vol >> 1) + 3, 0x32), 0, _size, 127);
+ _mod->startChannel(_id | 0x300, tmp_data4, _size, BASE_FREQUENCY / _freq4, MIN((_vol >> 1) + 3, 0x32), 0, _size, -127);
}
virtual bool update() {
assert(_id);
@@ -1068,10 +1068,10 @@
_vol--;
if (_vol == 0)
return false;
- _mod->setChannelVol(_id | 0x000, MIN((_vol >> 1) + 3,0x32));
- _mod->setChannelVol(_id | 0x100, MIN((_vol >> 1) + 3,0x32));
- _mod->setChannelVol(_id | 0x200, MIN((_vol >> 1) + 3,0x32));
- _mod->setChannelVol(_id | 0x300, MIN((_vol >> 1) + 3,0x32));
+ _mod->setChannelVol(_id | 0x000, MIN((_vol >> 1) + 3, 0x32));
+ _mod->setChannelVol(_id | 0x100, MIN((_vol >> 1) + 3, 0x32));
+ _mod->setChannelVol(_id | 0x200, MIN((_vol >> 1) + 3, 0x32));
+ _mod->setChannelVol(_id | 0x300, MIN((_vol >> 1) + 3, 0x32));
return true;
}
private:
@@ -1380,11 +1380,13 @@
_loop = 1;
_curfreq = 0x01F4;
- char *tmp_data = (char *)malloc(_size);
- memcpy(tmp_data, _data + _offset, _size);
- _mod->startChannel(_id | 0x000, tmp_data, _size, BASE_FREQUENCY / _curfreq, 0x7F, 0, _size, -127);
+ char *tmp_data1 = (char *)malloc(_size);
+ char *tmp_data2 = (char *)malloc(_size);
+ memcpy(tmp_data1, _data + _offset, _size);
+ memcpy(tmp_data2, _data + _offset, _size);
+ _mod->startChannel(_id | 0x000, tmp_data1, _size, BASE_FREQUENCY / _curfreq, 0x7F, 0, _size, -127);
// start 2nd channel silent
- _mod->startChannel(_id | 0x100, tmp_data, _size, BASE_FREQUENCY / _curfreq, 0, 0, _size, 127);
+ _mod->startChannel(_id | 0x100, tmp_data2, _size, BASE_FREQUENCY / _curfreq, 0, 0, _size, 127);
}
virtual bool update() {
assert(_id);
@@ -1434,11 +1436,13 @@
_loop = 1;
_curfreq = 0x0080;
- char *tmp_data = (char *)malloc(_size);
- memcpy(tmp_data, _data + _offset, _size);
- _mod->startChannel(_id | 0x000, tmp_data, _size, BASE_FREQUENCY / _curfreq, 0x7F, 0, _size, -127);
+ char *tmp_data1 = (char *)malloc(_size);
+ char *tmp_data2 = (char *)malloc(_size);
+ memcpy(tmp_data1, _data + _offset, _size);
+ memcpy(tmp_data2, _data + _offset, _size);
+ _mod->startChannel(_id | 0x000, tmp_data1, _size, BASE_FREQUENCY / _curfreq, 0x7F, 0, _size, -127);
// start 2nd channel silent
- _mod->startChannel(_id | 0x100, tmp_data, _size, BASE_FREQUENCY / _curfreq, 0, 0, _size, 127);
+ _mod->startChannel(_id | 0x100, tmp_data2, _size, BASE_FREQUENCY / _curfreq, 0, 0, _size, 127);
}
virtual bool update() {
assert(_id);
@@ -1688,7 +1692,7 @@
}
virtual bool update() {
assert(_id);
- const uint16 _minvol[2] = {0x2E,0x32};
+ const uint16 _minvol[2] = {0x2E, 0x32};
int i;
for (i = 0; i < 4; i++) {
_mod->setChannelFreq(_id | (i << 8), BASE_FREQUENCY / _freq[i]);
@@ -1908,7 +1912,7 @@
uint32 crc = GetCRC(data + 0x0A, READ_BE_UINT16(data + 0x08));
V2A_Sound *snd = findSound(crc);
if (snd == NULL) {
- warning("player_v2a - sound %i not recognized yet (crc %08X)",nr,crc);
+ warning("player_v2a - sound %i not recognized yet (crc %08X)", nr, crc);
return;
}
stopSound(nr);
@@ -1917,7 +1921,7 @@
return;
_slot[i].id = nr;
_slot[i].sound = snd;
- _slot[i].sound->start(_mod,nr,data);
+ _slot[i].sound->start(_mod, nr, data);
}
void Player_V2A::update_proc(void *param) {
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