]> git.tdb.fi Git - r2c2.git/commitdiff
Add an out-of-bounds check to SpeedQuantizer::get_speed
authorMikko Rasa <tdb@tdb.fi>
Thu, 11 Jul 2013 11:40:13 +0000 (14:40 +0300)
committerMikko Rasa <tdb@tdb.fi>
Thu, 11 Jul 2013 11:40:13 +0000 (14:40 +0300)
Just in case the previous fix wasn't the only place that could generate
bogus values.

source/libr2c2/speedquantizer.cpp

index fa7a4be8b31311d348118cb47c4237e0e59ae8c7..f2b14b8a2aa8d6f6d585562739f8c111d548d787 100644 (file)
@@ -22,6 +22,8 @@ void SpeedQuantizer::learn(unsigned i, float s, float w)
 
 float SpeedQuantizer::get_speed(unsigned i) const
 {
+       if(i>=steps.size())
+               throw out_of_range("SpeedQuantizer::get_speed");
        if(i==0)
                return 0;
        if(steps[i].weight>=weight_limit)