From ee99452158de5e2fa804bd10de7669848f3b3952 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 28 Feb 2025 14:53:58 -0300 Subject: Error object cannot be nil Lua will change a nil as error object to a string message, so that it never reports an error with nil as the error object. --- ldebug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'ldebug.c') diff --git a/ldebug.c b/ldebug.c index af3b7583..18bdc595 100644 --- a/ldebug.c +++ b/ldebug.c @@ -844,7 +844,9 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) { va_start(argp, fmt); msg = luaO_pushvfstring(L, fmt, argp); /* format message */ va_end(argp); - if (msg != NULL && isLua(ci)) { /* Lua function? (and no error) */ + if (msg == NULL) /* no memory to format message? */ + luaD_throw(L, LUA_ERRMEM); + else if (isLua(ci)) { /* Lua function? */ /* add source:line information */ luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci)); setobjs2s(L, L->top.p - 2, L->top.p - 1); /* remove 'msg' */ -- cgit v1.2.3-55-g6feb