From: <sag...@us...> - 2011-06-29 23:28:06
|
Revision: 908 http://modplug.svn.sourceforge.net/modplug/?rev=908&view=rev Author: saga-games Date: 2011-06-29 23:28:00 +0000 (Wed, 29 Jun 2011) Log Message: ----------- [Fix] MP3 export should no more result in a heap corruption and thus crash the tracker [Mod] OpenMPT: Version is now 1.19.02.08 Modified Paths: -------------- trunk/OpenMPT/mptrack/Mod2wave.cpp trunk/OpenMPT/mptrack/version.h Modified: trunk/OpenMPT/mptrack/Mod2wave.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mod2wave.cpp 2011-06-26 12:09:38 UTC (rev 907) +++ trunk/OpenMPT/mptrack/Mod2wave.cpp 2011-06-29 23:28:00 UTC (rev 908) @@ -999,11 +999,13 @@ // Open the ACM Driver if (theApp.AcmDriverOpen(&had, m_hadid, 0L) != MMSYSERR_NOERROR) goto OnError; if (theApp.AcmStreamOpen(&has, had, &wfxSrc, m_pwfx, NULL, 0L, 0L, ACM_STREAMOPENF_NONREALTIME) != MMSYSERR_NOERROR) goto OnError; - if (theApp.AcmStreamSize(has, WAVECONVERTBUFSIZE, &dwDstBufSize, ACM_STREAMSIZEF_SOURCE) != MMSYSERR_NOERROR) goto OnError; - if (dwDstBufSize > 0x10000) dwDstBufSize = 0x10000; - pcmBuffer = (LPBYTE)GlobalAllocPtr(GHND, WAVECONVERTBUFSIZE); - dstBuffer = (LPBYTE)GlobalAllocPtr(GHND, dwDstBufSize); + if (theApp.AcmStreamSize(has, WAVECONVERTBUFSIZE, &dwDstBufSize, ACM_STREAMSIZEF_SOURCE | ACM_STREAMSIZEF_DESTINATION) != MMSYSERR_NOERROR) goto OnError; + //if (dwDstBufSize > 0x10000) dwDstBufSize = 0x10000; + pcmBuffer = new BYTE[WAVECONVERTBUFSIZE]; + dstBuffer = new BYTE[dwDstBufSize]; if ((!dstBuffer) || (!pcmBuffer)) goto OnError; + memset(pcmBuffer, 0, WAVECONVERTBUFSIZE); + memset(dstBuffer, 0, dwDstBufSize); MemsetZero(ash); ash.cbStruct = sizeof(ash); ash.pbSrc = pcmBuffer; @@ -1114,6 +1116,7 @@ } if (ash.cbDstLengthUsed > 0) { + ASSERT(ash.cbDstLengthUsed <= dwDstBufSize); UINT lWrite = fwrite(dstBuffer, 1, ash.cbDstLengthUsed, f); if (!lWrite) break; wdh.length += lWrite; @@ -1169,8 +1172,8 @@ if (bPrepared) theApp.AcmStreamUnprepareHeader(has, &ash, 0L); if (has != NULL) theApp.AcmStreamClose(has, 0L); if (had != NULL) theApp.AcmDriverClose(had, 0L); - if (pcmBuffer) GlobalFreePtr(pcmBuffer); - if (dstBuffer) GlobalFreePtr(dstBuffer); + if (pcmBuffer) delete[] pcmBuffer; + if (dstBuffer) delete[] dstBuffer; //rewbs: reduce to normal priority during debug for easier hang debugging //SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS); SetPriorityClass(GetCurrentProcess(), NORMAL_PRIORITY_CLASS); Modified: trunk/OpenMPT/mptrack/version.h =================================================================== --- trunk/OpenMPT/mptrack/version.h 2011-06-26 12:09:38 UTC (rev 907) +++ trunk/OpenMPT/mptrack/version.h 2011-06-29 23:28:00 UTC (rev 908) @@ -15,7 +15,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 19 #define VER_MINOR 02 -#define VER_MINORMINOR 07 +#define VER_MINORMINOR 08 //Creates version number from version parts that appears in version string. //For example MAKE_VERSION_NUMERIC(1,17,02,28) gives version number of This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |