|
From: <man...@us...> - 2013-12-15 13:51:25
|
Revision: 3477
http://sourceforge.net/p/modplug/code/3477
Author: manxorist
Date: 2013-12-15 13:51:15 +0000 (Sun, 15 Dec 2013)
Log Message:
-----------
[Fix] Tuning: Correct a bogus check in CTuningBase::IsStepCountRangeSufficient which apparently tried to avoid integer overflows.
Modified Paths:
--------------
trunk/OpenMPT/soundlib/tuning.h
trunk/OpenMPT/soundlib/tuningbase.h
Modified: trunk/OpenMPT/soundlib/tuning.h
===================================================================
--- trunk/OpenMPT/soundlib/tuning.h 2013-12-15 12:30:03 UTC (rev 3476)
+++ trunk/OpenMPT/soundlib/tuning.h 2013-12-15 13:51:15 UTC (rev 3477)
@@ -158,7 +158,7 @@
std::vector<RATIOTYPE> m_RatioTableFine;
//The lowest index of note in the table
- NOTEINDEXTYPE m_StepMin;
+ NOTEINDEXTYPE m_StepMin; // this should REALLY be called 'm_NoteMin' renaming was missed in r192
//For groupgeometric tunings, tells the 'group size' and 'group ratio'
//m_GroupSize should always be >= 0.
Modified: trunk/OpenMPT/soundlib/tuningbase.h
===================================================================
--- trunk/OpenMPT/soundlib/tuningbase.h 2013-12-15 12:30:03 UTC (rev 3476)
+++ trunk/OpenMPT/soundlib/tuningbase.h 2013-12-15 13:51:15 UTC (rev 3477)
@@ -175,7 +175,7 @@
bool IsValidNote(const NOTEINDEXTYPE n) const {return (n >= GetValidityRange().first && n <= GetValidityRange().second);}
//Checking that step distances can be presented with
- //value range of STEPINDEXTYPE with given finestepcount ja validityrange.
+ //value range of STEPINDEXTYPE with given finestepcount and validityrange.
bool IsStepCountRangeSufficient(USTEPINDEXTYPE fs, VRPAIR vrp);
virtual const char* GetTuningTypeDescription() const;
@@ -301,9 +301,13 @@
inline bool CTuningBase::IsStepCountRangeSufficient(USTEPINDEXTYPE fs, VRPAIR vrp)
-//------------------------------------------------------------------
+//--------------------------------------------------------------------------------
{
- if(vrp.first == STEPINDEXTYPE_MIN && vrp.second == STEPINDEXTYPE_MAX) return true;
+ { // avoid integer overload
+ //if(vrp.first == STEPINDEXTYPE_MIN && vrp.second == STEPINDEXTYPE_MAX) return true;
+ ASSERT(NOTEINDEXTYPE_MIN / 2 < vrp.first && vrp.second < NOTEINDEXTYPE_MAX / 2);
+ if(NOTEINDEXTYPE_MIN / 2 >= vrp.first || vrp.second >= NOTEINDEXTYPE_MAX / 2) return true;
+ }
if(fs > static_cast<USTEPINDEXTYPE>(STEPINDEXTYPE_MAX) / (vrp.second - vrp.first + 1)) return false;
else return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|