1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-28 15:38:48 +01:00

Identify the few unsafe narrowing conversions from sampleCount...

... I believe this list of four places is exhaustive.

There are many, many more safe narrowings that I examined.

This resulted from changing the definition of sampleCount in my builds so that
narrowing conversions failed to compile without some fixes, and I examined and
fixed every place.

The rest of that work is not yet shared.
This commit is contained in:
Paul Licameli
2016-08-20 20:32:10 -04:00
parent 37687c589f
commit 1189cfd62a
4 changed files with 37 additions and 12 deletions

View File

@@ -848,7 +848,9 @@ void NumericConverter::ValueToControls(double rawValue, bool nearest /* = true *
}
else {
if (t_int >= 0) {
value = (t_int / mFields[i].base);
// UNSAFE_SAMPLE_COUNT_TRUNCATION
// truncation danger!
value = (static_cast<long long>( t_int ) / mFields[i].base);
if (mFields[i].range > 0)
value = value % mFields[i].range;
}