diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-11 14:42:06 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-09-11 14:42:06 +0100 |
commit | 4aff77e11f03a73875baec5c93af021a89189719 (patch) | |
tree | 742a6b2a084aaf814675dd7a0a567d519559b0a9 /src/lua/lua_common.c | |
parent | 0b4bffde43bb88131e76929219eecf609a018094 (diff) | |
download | rspamd-4aff77e11f03a73875baec5c93af021a89189719.tar.gz rspamd-4aff77e11f03a73875baec5c93af021a89189719.zip |
[Minor] Fix type check error message
Diffstat (limited to 'src/lua/lua_common.c')
-rw-r--r-- | src/lua/lua_common.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c index 92c9d0b61..ac7a393b8 100644 --- a/src/lua/lua_common.c +++ b/src/lua/lua_common.c @@ -1569,19 +1569,19 @@ err: if (fatal) { const gchar *actual_classname = NULL; - if (lua_getmetatable (L, pos)) { + if (lua_type (L, pos) == LUA_TUSERDATA && lua_getmetatable (L, pos)) { lua_pushstring (L, "__index"); - lua_gettable (L, -3); + lua_gettable (L, -2); lua_pushstring (L, "class"); lua_gettable (L, -2); actual_classname = lua_tostring (L, -1); } else { - actual_classname = lua_typename (L, lua_type (L, -1)); + actual_classname = lua_typename (L, lua_type (L, pos)); } err_msg = g_string_sized_new (100); - rspamd_printf_gstring (err_msg, "expected %s at %d, but userdata has " + rspamd_printf_gstring (err_msg, "expected %s at position %d, but userdata has " "%s metatable; trace: ", classname, pos, actual_classname); rspamd_lua_traceback_string (L, err_msg); @@ -1589,15 +1589,21 @@ err: for (i = 1; i <= MIN (top, 10); i ++) { if (lua_type (L, i) == LUA_TUSERDATA) { - lua_getmetatable (L, i); - lua_pushstring (L, "__index"); - lua_gettable (L, -3); - lua_pushstring (L, "class"); - lua_gettable (L, -2); + const char *clsname; + + if (lua_getmetatable (L, i)) { + lua_pushstring (L, "__index"); + lua_gettable (L, -2); + lua_pushstring (L, "class"); + lua_gettable (L, -2); + clsname = lua_tostring (L, -1); + } + else { + clsname = lua_typename (L, lua_type (L, i)); + } rspamd_printf_gstring (err_msg, "[%d: ud=%s] ", i, - lua_tostring (L, -1)); - lua_pop (L, 3); + clsname); } else { rspamd_printf_gstring (err_msg, "[%d: %s] ", i, |