From 7fac28fcb5afb17eff7c459474e4cf884a02719c Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 11 Jul 2013 14:40:13 +0300 Subject: [PATCH] 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. --- source/libr2c2/speedquantizer.cpp | 2 ++ 1 file changed, 2 insertions(+) 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) -- 2.43.0