From: <man...@us...> - 2015-04-25 10:23:44
|
Revision: 4990 http://sourceforge.net/p/modplug/code/4990 Author: manxorist Date: 2015-04-25 10:23:39 +0000 (Sat, 25 Apr 2015) Log Message: ----------- [Fix] Fix various problems and possible crashes spotted by VS2010 static analyzer. Modified Paths: -------------- trunk/OpenMPT/common/mptFileIO.h trunk/OpenMPT/common/mptString.cpp trunk/OpenMPT/common/serialization_utils.cpp trunk/OpenMPT/soundlib/Load_ams.cpp trunk/OpenMPT/soundlib/Load_stm.cpp trunk/OpenMPT/soundlib/Mmcmp.cpp trunk/OpenMPT/soundlib/pattern.cpp Modified: trunk/OpenMPT/common/mptFileIO.h =================================================================== --- trunk/OpenMPT/common/mptFileIO.h 2015-04-24 21:05:15 UTC (rev 4989) +++ trunk/OpenMPT/common/mptFileIO.h 2015-04-25 10:23:39 UTC (rev 4990) @@ -34,7 +34,7 @@ //------------------------------------------------------------------------------- { #if MPT_OS_WINDOWS - return _wfopen(filename.AsNative().c_str(), mode ? mpt::ToWide(mpt::CharsetASCII, mode).c_str() : nullptr); + return _wfopen(filename.AsNative().c_str(), mode ? mpt::ToWide(mpt::CharsetASCII, mode).c_str() : L""); #else // !MPT_OS_WINDOWS return fopen(filename.AsNative().c_str(), mode); #endif // MPT_OS_WINDOWS Modified: trunk/OpenMPT/common/mptString.cpp =================================================================== --- trunk/OpenMPT/common/mptString.cpp 2015-04-24 21:05:15 UTC (rev 4989) +++ trunk/OpenMPT/common/mptString.cpp 2015-04-25 10:23:39 UTC (rev 4990) @@ -201,7 +201,7 @@ for(std::size_t i = 0; i < str.length(); ++i) { uint32 c = static_cast<uint32>(static_cast<uint8>(str[i])); - if(c <= CountOf(table)) + if(c < CountOf(table)) { res.push_back(static_cast<wchar_t>(static_cast<uint32>(table[c]))); } else Modified: trunk/OpenMPT/common/serialization_utils.cpp =================================================================== --- trunk/OpenMPT/common/serialization_utils.cpp 2015-04-24 21:05:15 UTC (rev 4989) +++ trunk/OpenMPT/common/serialization_utils.cpp 2015-04-25 10:23:39 UTC (rev 4990) @@ -54,7 +54,7 @@ { for(std::size_t i = 0; i < m_ID.length(); ++i) { - if(m_ID[i] <= 0 || isprint(m_ID[i]) == 0) + if(m_ID[i] <= 0 || isprint(static_cast<unsigned char>(m_ID[i])) == 0) { return false; } Modified: trunk/OpenMPT/soundlib/Load_ams.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_ams.cpp 2015-04-24 21:05:15 UTC (rev 4989) +++ trunk/OpenMPT/soundlib/Load_ams.cpp 2015-04-25 10:23:39 UTC (rev 4990) @@ -97,7 +97,7 @@ CMD_GLOBALVOLUME, // Global volume (0... 127) }; - ModCommand dummy; + ModCommand dummy = ModCommand::Empty(); for(ROWINDEX row = 0; row < pattern.GetNumRows(); row++) { Modified: trunk/OpenMPT/soundlib/Load_stm.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_stm.cpp 2015-04-24 21:05:15 UTC (rev 4989) +++ trunk/OpenMPT/soundlib/Load_stm.cpp 2015-04-25 10:23:39 UTC (rev 4990) @@ -90,7 +90,7 @@ // Convert all multi-byte numeric values to current platform's endianness or vice versa. void ConvertEndianness() { - for(std::size_t i = 0; i < 32; ++i) + for(std::size_t i = 0; i < 31; ++i) { samples[i].ConvertEndianness(); } Modified: trunk/OpenMPT/soundlib/Mmcmp.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmcmp.cpp 2015-04-24 21:05:15 UTC (rev 4989) +++ trunk/OpenMPT/soundlib/Mmcmp.cpp 2015-04-25 10:23:39 UTC (rev 4990) @@ -248,6 +248,7 @@ { MMCMPBITBUFFER bb; uint32 subblk = 0; + if(!psubblk) return false; if(!MMCMP_IsDstBlockValid(unpackedData, psubblk[subblk])) return false; char *pDest = &(unpackedData[psubblk[subblk].unpk_pos]); uint32 dwSize = psubblk[subblk].unpk_size >> 1; Modified: trunk/OpenMPT/soundlib/pattern.cpp =================================================================== --- trunk/OpenMPT/soundlib/pattern.cpp 2015-04-24 21:05:15 UTC (rev 4989) +++ trunk/OpenMPT/soundlib/pattern.cpp 2015-04-25 10:23:39 UTC (rev 4990) @@ -619,7 +619,7 @@ mpt::IO::ReadIntLE<uint8>(iStrm, diffmask); uint8 temp = 0; - ModCommand dummy; + ModCommand dummy = ModCommand::Empty(); ModCommand& m = (ch < chns) ? *pat.GetpModCommand(row, ch) : dummy; READITEM(noteBit, note); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |