diff options
author | daurnimator <quae@daurnimator.com> | 2017-11-12 16:37:50 +1100 |
---|---|---|
committer | daurnimator <quae@daurnimator.com> | 2017-11-12 16:37:50 +1100 |
commit | d8caec5b1dc33cc3a89a1995b0e1a30ba0301184 (patch) | |
tree | 112266a53a28eb15efb04547c5426ff1bf215bc3 /src/lbaselib.js | |
parent | c350b68df9539749cbde7254685d8d7cd7e466c7 (diff) | |
download | fengari-d8caec5b1dc33cc3a89a1995b0e1a30ba0301184.tar.gz fengari-d8caec5b1dc33cc3a89a1995b0e1a30ba0301184.tar.bz2 fengari-d8caec5b1dc33cc3a89a1995b0e1a30ba0301184.zip |
src/lbaselib.js: Add try/catch around to_jsstring call in tonumber
Diffstat (limited to 'src/lbaselib.js')
-rw-r--r-- | src/lbaselib.js | 7 |
1 files changed, 6 insertions, 1 deletions
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]; |