aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2018-09-17 08:56:18 -0500
committertlatorre <tlatorre@uchicago.edu>2018-09-17 08:56:18 -0500
commitef3fac58f9342d98b1f86e00c4dcb1dbbbe9f1a8 (patch)
treea54f53a071254523291ed3122f49b31e73d846ae
parente1bbfc7ef85800f0e0f5e422bdef3b55d88e597e (diff)
downloadsddm-ef3fac58f9342d98b1f86e00c4dcb1dbbbe9f1a8.tar.gz
sddm-ef3fac58f9342d98b1f86e00c4dcb1dbbbe9f1a8.tar.bz2
sddm-ef3fac58f9342d98b1f86e00c4dcb1dbbbe9f1a8.zip
fix a bug in interp1d()
This commit fixes a bug in interp1d() which would cause the function to read past the end of the arrays if the interpolation point was equal to the last point in the xp array.
-rw-r--r--src/misc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/misc.c b/src/misc.c
index 823bc78..f0e37e3 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -269,8 +269,8 @@ double interp1d(double x, double *xp, double *yp, size_t n)
* If x < xp[0] returns yp[0] and if x > xp[n-1] returns yp[n-1]. */
size_t i;
- if (x < xp[0]) return yp[0];
- if (x > xp[n-1]) return yp[n-1];
+ if (x <= xp[0]) return yp[0];
+ if (x >= xp[n-1]) return yp[n-1];
i = (x-xp[0])/(xp[1]-xp[0]);