From 4a7c4ced98ae6f9006237d623e7c5e2d9367b805 Mon Sep 17 00:00:00 2001 From: Albert Graef Date: Wed, 4 Sep 2024 04:04:33 +0200 Subject: [PATCH] Check filename argument in dofile/dofilex. --- pdlua.c | 2 ++ pdlua/tutorial/examples/pdx.lua | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pdlua.c b/pdlua.c index b45892d..6533238 100644 --- a/pdlua.c +++ b/pdlua.c @@ -2260,6 +2260,7 @@ static int pdlua_dofilex(lua_State *L) if (c) { filename = luaL_optstring(L, 2, NULL); + if (!filename) return 0; fd = trytoopenone(c->c_externdir->s_name, filename, "", buf, &ptr, MAXPDSTRING, 1); if (fd >= 0) @@ -2331,6 +2332,7 @@ static int pdlua_dofile(lua_State *L) if (o) { filename = luaL_optstring(L, 2, NULL); + if (!filename) return 0; fd = canvas_open(o->canvas, filename, "", buf, &ptr, MAXPDSTRING, 1); if (fd >= 0) { diff --git a/pdlua/tutorial/examples/pdx.lua b/pdlua/tutorial/examples/pdx.lua index 91fafa9..d2096e4 100644 --- a/pdlua/tutorial/examples/pdx.lua +++ b/pdlua/tutorial/examples/pdx.lua @@ -74,7 +74,7 @@ end -- present this only recognizes the "reload" message and checks the class -- name, if given. local function pdluax(self, sel, atoms) - if sel == "reload" then + if sel == "reload" and not string.match(self._scriptname, ".pd_luax$") then -- reload message, check that any extra argument matches the class name if atoms[1] == nil or atoms[1] == self._name then -- invoke the prereload method if it exists