[Scummvm-cvs-logs] SF.net SVN: scummvm: [23918] scummvm/branches/branch-0-9-0
eriktorbjorn at users.sourceforge.net
eriktorbjorn at users.sourceforge.net
Sun Sep 17 17:37:17 CEST 2006
Revision: 23918
http://svn.sourceforge.net/scummvm/?rev=23918&view=rev
Author: eriktorbjorn
Date: 2006-09-17 08:37:10 -0700 (Sun, 17 Sep 2006)
Log Message:
-----------
Backported fix for speech-related crashes in the BS1 demo.
Modified Paths:
--------------
scummvm/branches/branch-0-9-0/NEWS
scummvm/branches/branch-0-9-0/engines/sword1/sound.cpp
Modified: scummvm/branches/branch-0-9-0/NEWS
===================================================================
--- scummvm/branches/branch-0-9-0/NEWS 2006-09-17 15:25:59 UTC (rev 23917)
+++ scummvm/branches/branch-0-9-0/NEWS 2006-09-17 15:37:10 UTC (rev 23918)
@@ -22,6 +22,9 @@
BASS:
- Fixed character spacing in LINC terminals in floppy version v0.0303
+ Broken Sword 1:
+ - Fixed speech-related crashes.
+
Broken Sword 2:
- More robust handling of the optional startup.inf file.
Modified: scummvm/branches/branch-0-9-0/engines/sword1/sound.cpp
===================================================================
--- scummvm/branches/branch-0-9-0/engines/sword1/sound.cpp 2006-09-17 15:25:59 UTC (rev 23917)
+++ scummvm/branches/branch-0-9-0/engines/sword1/sound.cpp 2006-09-17 15:37:10 UTC (rev 23918)
@@ -260,24 +260,30 @@
uint32 srcPos = headerPos >> 1;
cSize /= 2;
uint32 dstPos = 0;
- /* alloc 200 additional bytes, as the demo sometimes has ASCII junk
- at the end of the wave data */
- int16 *dstData = (int16*)malloc(resSize * 2 + 200);
- while (srcPos < cSize) {
+ int16 *dstData = (int16*)malloc(resSize * 2);
+ int32 samplesLeft = resSize;
+ while (srcPos < cSize && samplesLeft > 0) {
int16 length = (int16)READ_LE_UINT16(srcData + srcPos);
srcPos++;
if (length < 0) {
length = -length;
+ if (length > samplesLeft)
+ length = samplesLeft;
for (uint16 cnt = 0; cnt < (uint16)length; cnt++)
dstData[dstPos++] = srcData[srcPos];
srcPos++;
} else {
+ if (length > samplesLeft)
+ length = samplesLeft;
memcpy(dstData + dstPos, srcData + srcPos, length * 2);
dstPos += length;
srcPos += length;
}
+ samplesLeft -= length;
}
- assert(dstPos < (uint32)resSize + 100);
+ if (samplesLeft > 0) {
+ memset(dstData + dstPos, 0, samplesLeft * 2);
+ }
if (_cowMode == CowDemo) // demo has wave output size embedded in the compressed data
*(uint32*)dstData = 0;
free(fBuf);
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