aboutsummaryrefslogtreecommitdiff
path: root/ldebug.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-02-28 14:53:58 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2025-02-28 14:53:58 -0300
commitee99452158de5e2fa804bd10de7669848f3b3952 (patch)
treea68b8834ef0f61f9a7a2ce297ab3963cec8e56d9 /ldebug.c
parent127a8e80fe0d74efd26994b3877cdc77b712ea56 (diff)
downloadlua-ee99452158de5e2fa804bd10de7669848f3b3952.tar.gz
lua-ee99452158de5e2fa804bd10de7669848f3b3952.tar.bz2
lua-ee99452158de5e2fa804bd10de7669848f3b3952.zip
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.
Diffstat (limited to 'ldebug.c')
-rw-r--r--ldebug.c4
1 files changed, 3 insertions, 1 deletions
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, ...) {
844 va_start(argp, fmt); 844 va_start(argp, fmt);
845 msg = luaO_pushvfstring(L, fmt, argp); /* format message */ 845 msg = luaO_pushvfstring(L, fmt, argp); /* format message */
846 va_end(argp); 846 va_end(argp);
847 if (msg != NULL && isLua(ci)) { /* Lua function? (and no error) */ 847 if (msg == NULL) /* no memory to format message? */
848 luaD_throw(L, LUA_ERRMEM);
849 else if (isLua(ci)) { /* Lua function? */
848 /* add source:line information */ 850 /* add source:line information */
849 luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci)); 851 luaG_addinfo(L, msg, ci_func(ci)->p->source, getcurrentline(ci));
850 setobjs2s(L, L->top.p - 2, L->top.p - 1); /* remove 'msg' */ 852 setobjs2s(L, L->top.p - 2, L->top.p - 1); /* remove 'msg' */