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.
This commit is contained in:
4
ldebug.c
4
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' */
|
||||
|
||||
Reference in New Issue
Block a user