aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
authorRoberto I <roberto@inf.puc-rio.br>2026-04-07 13:42:34 -0300
committerRoberto I <roberto@inf.puc-rio.br>2026-04-07 13:42:34 -0300
commit29cf284089d543408d726440a3f1acaecdf73636 (patch)
treee18363e7d53bb64d6f82943556ff0c3110778837 /lbaselib.c
parentc037162a1a657088d722f550e287015525bb2259 (diff)
downloadlua-29cf284089d543408d726440a3f1acaecdf73636.tar.gz
lua-29cf284089d543408d726440a3f1acaecdf73636.tar.bz2
lua-29cf284089d543408d726440a3f1acaecdf73636.zip
Avoid macros luaL_loadbuffer and luaL_loadfile
Use luaL_loadbufferx and luaL_loadfilex instead, being explicit about whether to accept binary chunks.
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/lbaselib.c b/lbaselib.c
index 891bb90f..47f7bdec 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -340,9 +340,11 @@ static int load_aux (lua_State *L, int status, int envidx) {
340 340
341 341
342static const char *getMode (lua_State *L, int idx) { 342static const char *getMode (lua_State *L, int idx) {
343 const char *mode = luaL_optstring(L, idx, "bt"); 343 const char *mode = luaL_optstring(L, idx, NULL);
344 if (strchr(mode, 'B') != NULL) /* Lua code cannot use fixed buffers */ 344 if (mode != NULL && strchr(mode, 'B') != NULL) {
345 /* Lua code cannot use fixed buffers */
345 luaL_argerror(L, idx, "invalid mode"); 346 luaL_argerror(L, idx, "invalid mode");
347 }
346 return mode; 348 return mode;
347} 349}
348 350
@@ -425,7 +427,7 @@ static int dofilecont (lua_State *L, int d1, lua_KContext d2) {
425static int luaB_dofile (lua_State *L) { 427static int luaB_dofile (lua_State *L) {
426 const char *fname = luaL_optstring(L, 1, NULL); 428 const char *fname = luaL_optstring(L, 1, NULL);
427 lua_settop(L, 1); 429 lua_settop(L, 1);
428 if (l_unlikely(luaL_loadfile(L, fname) != LUA_OK)) 430 if (l_unlikely(luaL_loadfilex(L, fname, "bt") != LUA_OK))
429 return lua_error(L); 431 return lua_error(L);
430 lua_callk(L, 0, LUA_MULTRET, 0, dofilecont); 432 lua_callk(L, 0, LUA_MULTRET, 0, dofilecont);
431 return dofilecont(L, 0, 0); 433 return dofilecont(L, 0, 0);