From 810ccd037dd2791653be5fddb4e6140929d3787b Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 3 Nov 2013 23:15:09 +0000 Subject: [PATCH] Sanity check axis reads --- similar/main/kconfig.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/similar/main/kconfig.cpp b/similar/main/kconfig.cpp index d037022b8..33a467d98 100644 --- a/similar/main/kconfig.cpp +++ b/similar/main/kconfig.cpp @@ -23,6 +23,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include #include #include +#include #include "dxxerror.h" #include "pstypes.h" @@ -1272,8 +1273,12 @@ void kconfig(int n, const char * title) } template -static void adjust_axis_field(fix& time, const fix (&axes)[N], unsigned value, unsigned invert, int sensitivity) +static void adjust_axis_field(fix& time, const fix (&axes)[N], unsigned value, unsigned invert, const int& sensitivity) { + if (value == 255) + return; + if (value >= sizeof(axes) / sizeof(axes[0])) + throw std::out_of_range("value exceeds axes count"); fix amount = (axes[value]*sensitivity)/8; if ( !invert ) // If not inverted... time -= amount;