From 85fe99064287b6ee9a373b120ff19f044cb468ec Mon Sep 17 00:00:00 2001 From: David Crosby Date: Sat, 5 Sep 2015 18:47:12 -0600 Subject: Fix stack overflow found by @kcwu --- table.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/table.c b/table.c index b77f0f8..2a0aa8f 100644 --- a/table.c +++ b/table.c @@ -188,7 +188,7 @@ dv2sv(double *dv, short *iv, int size) indexarray = NewAtom_N(short, size); edv = NewAtom_N(double, size); for (i = 0; i < size; i++) { - iv[i] = ceil(dv[i]); + iv[i] = (short) ceil(dv[i]); edv[i] = (double)iv[i] - dv[i]; } @@ -205,7 +205,7 @@ dv2sv(double *dv, short *iv, int size) indexarray[i] = k; } iw = min((int)(w + 0.5), size); - if (iw == 0) + if (iw <= 1) return; x = edv[(int)indexarray[iw - 1]]; for (i = 0; i < size; i++) { -- cgit v1.2.3