From 43666c47b550904e5573e28fab6ba9d2c51ddcd3 Mon Sep 17 00:00:00 2001 From: Adam Chlipala Date: Sun, 10 Mar 2019 15:37:40 -0400 Subject: JavaScript string subscripting should raise out-of-bounds exceptions --- lib/js/urweb.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/js/urweb.js b/lib/js/urweb.js index 1c296fe1..749e5056 100644 --- a/lib/js/urweb.js +++ b/lib/js/urweb.js @@ -2493,6 +2493,8 @@ function id(x) { return x; } function sub(s, i) { var ch = undefined; iterateString(s, function(c, idx) { if (idx == i) { ch = c; return false; }}); + if (ch == undefined) + er("String index " + i + " out of bounds") return ch; } function suf(s, i) { -- cgit v1.2.3