aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-11-12 16:37:50 +1100
committerdaurnimator <quae@daurnimator.com>2017-11-12 16:37:50 +1100
commitd8caec5b1dc33cc3a89a1995b0e1a30ba0301184 (patch)
tree112266a53a28eb15efb04547c5426ff1bf215bc3
parentc350b68df9539749cbde7254685d8d7cd7e466c7 (diff)
downloadfengari-d8caec5b1dc33cc3a89a1995b0e1a30ba0301184.tar.gz
fengari-d8caec5b1dc33cc3a89a1995b0e1a30ba0301184.tar.bz2
fengari-d8caec5b1dc33cc3a89a1995b0e1a30ba0301184.zip
src/lbaselib.js: Add try/catch around to_jsstring call in tonumber
-rw-r--r--src/lbaselib.js7
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];