From: Mikko Rasa Date: Thu, 11 Jul 2013 11:40:13 +0000 (+0300) Subject: Add an out-of-bounds check to SpeedQuantizer::get_speed X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=7fac28fcb5afb17eff7c459474e4cf884a02719c;p=r2c2.git Add an out-of-bounds check to SpeedQuantizer::get_speed Just in case the previous fix wasn't the only place that could generate bogus values. --- diff --git a/source/libr2c2/speedquantizer.cpp b/source/libr2c2/speedquantizer.cpp index fa7a4be..f2b14b8 100644 --- a/source/libr2c2/speedquantizer.cpp +++ b/source/libr2c2/speedquantizer.cpp @@ -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)