From: Vsevolod Stakhov Date: Tue, 10 Jul 2018 12:46:36 +0000 (+0100) Subject: [Minor] Do not print pointer if successfully converted UD to a string X-Git-Tag: 1.7.8~9 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b37be54bd865543de40444c95fd6974bbf85609e;p=rspamd.git [Minor] Do not print pointer if successfully converted UD to a string --- 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;