From d8caec5b1dc33cc3a89a1995b0e1a30ba0301184 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 12 Nov 2017 16:37:50 +1100 Subject: src/lbaselib.js: Add try/catch around to_jsstring call in tonumber --- src/lbaselib.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lbaselib.js b/src/lbaselib.js index eb12280..c598474 100644 --- a/src/lbaselib.js +++ b/src/lbaselib.js @@ -169,7 +169,12 @@ const luaB_ipairs = function(L) { }; const b_str2int = function(s, base) { - let r = /^[\t\v\f \n\r]*([\+\-]?)0*([0-9A-Za-z]+)[\t\v\f \n\r]*$/.exec(lua.to_jsstring(s)); + try { + s = lua.to_jsstring(s); + } catch (e) { + return null; + } + let r = /^[\t\v\f \n\r]*([\+\-]?)0*([0-9A-Za-z]+)[\t\v\f \n\r]*$/.exec(s); if (!r) return null; let neg = r[1] === "-"; let digits = r[2]; -- cgit v1.2.3-70-g09d2