ref: 8f62ea10a0af68e56d5c00720523ebcba13c2e6a
parent: 7e00def3c3c79534f1368a0b5bc0697b19683e60
author: Tor Andersson <tor.andersson@gmail.com>
date: Tue Jan 24 09:32:14 EST 2017
Fix 697496: Check NAN before accessing array in MakeDay().
--- a/jsdate.c
+++ b/jsdate.c
@@ -207,12 +207,17 @@
};
double yd, md;
+ int im;
y += floor(m / 12);
m = pmod(m, 12);
+ im = (int)m;
+ if (im < 0 || im >= 12)
+ return NAN;
+
yd = floor(TimeFromYear(y) / msPerDay);
- md = firstDayOfMonth[InLeapYear(y)][(int)m];
+ md = firstDayOfMonth[InLeapYear(y)][im];
return yd + md + date - 1;
}