We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0d1c959 commit 9e10f9fCopy full SHA for 9e10f9f
src/script/cpp_api/s_security.cpp
@@ -525,14 +525,19 @@ int ScriptApiSecurity::sl_g_require(lua_State *L)
525
526
int ScriptApiSecurity::sl_io_open(lua_State *L)
527
{
528
+ bool with_mode = lua_gettop(L) > 1;
529
+
530
luaL_checktype(L, 1, LUA_TSTRING);
531
const char *path = lua_tostring(L, 1);
532
CHECK_SECURE_PATH(L, path);
533
534
push_original(L, "io", "open");
535
lua_pushvalue(L, 1);
- lua_pushvalue(L, 2);
- lua_call(L, 2, 2);
536
+ if (with_mode) {
537
+ lua_pushvalue(L, 2);
538
+ }
539
540
+ lua_call(L, with_mode ? 2 : 1, 2);
541
return 2;
542
}
543
0 commit comments