From: <sag...@us...> - 2014-04-09 19:20:35
|
Revision: 4007 http://sourceforge.net/p/modplug/code/4007 Author: saga-games Date: 2014-04-09 19:20:28 +0000 (Wed, 09 Apr 2014) Log Message: ----------- [Fix] Duplicating a sample through the treeview tried to allocate way too much memory, which could result in crashes (http://bugs.openmpt.org/view.php?id=505) [Mod] OpenMPT: Version is now 1.23.01.02. Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/Modedit.cpp Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-04-09 19:13:07 UTC (rev 4006) +++ trunk/OpenMPT/common/versionNumber.h 2014-04-09 19:20:28 UTC (rev 4007) @@ -17,7 +17,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 23 #define VER_MINOR 01 -#define VER_MINORMINOR 01 +#define VER_MINORMINOR 02 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/Modedit.cpp =================================================================== --- trunk/OpenMPT/mptrack/Modedit.cpp 2014-04-09 19:13:07 UTC (rev 4006) +++ trunk/OpenMPT/mptrack/Modedit.cpp 2014-04-09 19:20:28 UTC (rev 4007) @@ -335,9 +335,15 @@ if(--sampleCount[origSlot] > 0 && sampleHeaders[origSlot].pSample != nullptr) { // This sample slot is referenced multiple times, so we have to copy the actual sample. - target.pSample = ModSample::AllocateSample(target.nLength, target.GetSampleSizeInBytes()); - memcpy(target.pSample, sampleHeaders[origSlot].pSample, target.GetSampleSizeInBytes()); - target.PrecomputeLoops(m_SndFile, false); + target.pSample = ModSample::AllocateSample(target.nLength, target.GetBytesPerSample()); + if(target.pSample != nullptr) + { + memcpy(target.pSample, sampleHeaders[origSlot].pSample, target.GetBytesPerSample()); + target.PrecomputeLoops(m_SndFile, false); + } else + { + Reporting::Error("Cannot duplicate sample - out of memory!"); + } } strcpy(m_SndFile.m_szNames[i + 1], sampleNames[origSlot].c_str()); } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |