diff --git a/src/basic/vx_math/ptile.cc b/src/basic/vx_math/ptile.cc
index 953d5e5598..97c444e15f 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];
    }