diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-02-28 14:53:58 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2025-02-28 14:53:58 -0300 |
commit | ee99452158de5e2fa804bd10de7669848f3b3952 (patch) | |
tree | a68b8834ef0f61f9a7a2ce297ab3963cec8e56d9 /ldebug.c | |
parent | 127a8e80fe0d74efd26994b3877cdc77b712ea56 (diff) | |
download | lua-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.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -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' */ |