From 886d59eecc33e4a96b247b3f729e607df351b416 Mon Sep 17 00:00:00 2001 From: John Halley Gotway Date: Mon, 14 Aug 2023 15:32:08 -0600 Subject: [PATCH] Per #2644, additional range checking to handle bad input values of t. --- src/basic/vx_math/ptile.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic/vx_math/ptile.cc b/src/basic/vx_math/ptile.cc index b9b0d20da9..75b834f934 100644 --- a/src/basic/vx_math/ptile.cc +++ b/src/basic/vx_math/ptile.cc @@ -72,7 +72,7 @@ if ( n > 0 ) { p = ordered_array[index]; } // Interpolate linearly between two values - else { + else if ( index >= 0 && index < (n - 1) ) { delta = (n - 1)*t - index; p = (1 - delta)*ordered_array[index] + delta*ordered_array[index + 1]; } @@ -119,7 +119,7 @@ if ( n > 0 ) { p = ordered_array[index]; } // Interpolate linearly between two values - else { + else if ( index >= 0 && index < (n - 1) ) { delta = (n - 1)*t - index; p = (1 - delta)*ordered_array[index] + delta*ordered_array[index + 1]; }