1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-01 08:29:27 +02:00

fix some potential integer overflows with very long clips - not complete but Steve's testing indicates it probably helps

This commit is contained in:
RichardAsh1981@gmail.com 2013-12-11 22:36:07 +00:00
parent a866701d7e
commit e4f9578d3b

View File

@ -593,7 +593,7 @@ void TimeConverter::ValueToControls(double RawTime, bool nearest /* = true */)
//RawTime = 4.9995f; Only for testing! //RawTime = 4.9995f; Only for testing!
RawTime = (double)((sampleCount)floor(RawTime * mSampleRate + (nearest ? 0.5f : 0.0f))) / mSampleRate; // put on a sample RawTime = (double)((sampleCount)floor(RawTime * mSampleRate + (nearest ? 0.5f : 0.0f))) / mSampleRate; // put on a sample
double theValue = RawTime * mScalingFactor + .000001; // what's this .000001 for? double theValue = RawTime * mScalingFactor + .000001; // what's this .000001 for?
int t_int; sampleCount t_int;
bool round = true; bool round = true;
// We round on the last field. If we have a fractional field we round using it. // We round on the last field. If we have a fractional field we round using it.
// Otherwise we round to nearest integer. // Otherwise we round to nearest integer.
@ -602,12 +602,12 @@ void TimeConverter::ValueToControls(double RawTime, bool nearest /* = true */)
round = false; round = false;
} }
if(round) if(round)
t_int = int(theValue + (nearest ? 0.5f : 0.0f)); t_int = sampleCount(theValue + (nearest ? 0.5f : 0.0f));
else else
{ {
wxASSERT( mFields[mFields.GetCount()-1].frac ); wxASSERT( mFields[mFields.GetCount()-1].frac );
theValue += (nearest ? 0.5f : 0.0f) / mFields[mFields.GetCount()-1].base; theValue += (nearest ? 0.5f : 0.0f) / mFields[mFields.GetCount()-1].base;
t_int = int(theValue); t_int = sampleCount(theValue);
} }
double t_frac = (theValue - t_int); double t_frac = (theValue - t_int);
unsigned int i; unsigned int i;