diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-10 13:46:36 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-07-10 13:46:36 +0100 |
commit | b37be54bd865543de40444c95fd6974bbf85609e (patch) | |
tree | b7fbeb7ab3124d59fac0b5082d4b0e8219806f18 /src | |
parent | ccefb8665119b448f650e8aa2b0c79b8d657bc1d (diff) | |
download | rspamd-b37be54bd865543de40444c95fd6974bbf85609e.tar.gz rspamd-b37be54bd865543de40444c95fd6974bbf85609e.zip |
[Minor] Do not print pointer if successfully converted UD to a string
Diffstat (limited to 'src')
-rw-r--r-- | src/lua/lua_logger.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lua/lua_logger.c b/src/lua/lua_logger.c index f112b4dfc..a1297563b 100644 --- a/src/lua/lua_logger.c +++ b/src/lua/lua_logger.c @@ -319,6 +319,7 @@ lua_logger_out_userdata (lua_State *L, gint pos, gchar *outbuf, gsize len) { gint r, top; const gchar *str = NULL; + gboolean converted_to_str = FALSE; top = lua_gettop (L); @@ -348,6 +349,10 @@ lua_logger_out_userdata (lua_State *L, gint pos, gchar *outbuf, gsize len) } str = lua_tostring (L, -1); + + if (str) { + converted_to_str = TRUE; + } } else { lua_pushstring (L, "class"); @@ -362,7 +367,14 @@ lua_logger_out_userdata (lua_State *L, gint pos, gchar *outbuf, gsize len) str = lua_tostring (L, -1); } - r = rspamd_snprintf (outbuf, len + 1, "%s(%p)", str, lua_touserdata (L, pos)); + if (converted_to_str) { + r = rspamd_snprintf (outbuf, len + 1, "%s", str); + } + else { + /* Print raw pointer */ + r = rspamd_snprintf (outbuf, len + 1, "%s(%p)", str, lua_touserdata (L, pos)); + } + lua_settop (L, top); return r; |