From e85cbc442332876f48a4e0073f18bf821775a38e Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 4 Jul 2019 12:01:57 +0100 Subject: [Minor] Allow lua_text for opaque transition --- src/lua/lua_worker.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/lua/lua_worker.c b/src/lua/lua_worker.c index 8b69b71ef..273bcb63b 100644 --- a/src/lua/lua_worker.c +++ b/src/lua/lua_worker.c @@ -292,7 +292,7 @@ rspamd_lua_execute_lua_subprocess (lua_State *L, { gint err_idx, r; guint64 wlen = 0; - const gchar *ret; + const gchar *ret = NULL; gsize retlen; lua_pushcfunction (L, &rspamd_lua_traceback); @@ -319,15 +319,27 @@ rspamd_lua_execute_lua_subprocess (lua_State *L, } } else { - ret = lua_tolstring (L, -1, &retlen); - wlen = retlen; + if (lua_type (L, -1) == LUA_TSTRING) { + ret = lua_tolstring (L, -1, &retlen); + wlen = retlen; + } + else { + struct rspamd_lua_text *t; + + t = lua_check_text (L, -1); + + if (t) { + ret = t->start; + wlen = t->len; + } + } r = write (cbdata->sp[1], &wlen, sizeof (wlen)); if (r == -1) { msg_err ("write failed: %s", strerror (errno)); } - r = write (cbdata->sp[1], ret, retlen); + r = write (cbdata->sp[1], ret, wlen); if (r == -1) { msg_err ("write failed: %s", strerror (errno)); } -- cgit v1.2.3