From 89d049c7a3a68bbeffa262bf3bf6fa3bcb83d176 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 4 Feb 2018 16:06:51 -0800 Subject: src/lauxlib.js: Check default value when using luaL_optstring --- src/lauxlib.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lauxlib.js b/src/lauxlib.js index d5b943b..15d8dab 100644 --- a/src/lauxlib.js +++ b/src/lauxlib.js @@ -76,6 +76,7 @@ const { lua_version } = require('./lua.js'); const { + from_userstring, luastring_eq, to_luastring, to_uristring @@ -366,7 +367,7 @@ const luaL_checkudata = function(L, ud, tname) { }; const luaL_checkoption = function(L, arg, def, lst) { - let name = def ? luaL_optstring(L, arg, def) : luaL_checkstring(L, arg); + let name = def !== null ? luaL_optstring(L, arg, def) : luaL_checkstring(L, arg); for (let i = 0; lst[i]; i++) if (luastring_eq(lst[i], name)) return i; @@ -414,7 +415,7 @@ const luaL_checklstring = function(L, arg) { const luaL_optlstring = function(L, arg, def) { if (lua_type(L, arg) <= 0) { - return def; + return def === null ? null : from_userstring(def); } else return luaL_checklstring(L, arg); }; -- cgit v1.2.3-70-g09d2