summaryrefslogtreecommitdiff
path: root/src/lbaselib.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/lbaselib.js')
-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];