aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-04 12:01:57 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-07-04 12:01:57 +0100
commite85cbc442332876f48a4e0073f18bf821775a38e (patch)
treea0993d91ec803d290d718f36edc5e5356b881c71 /src
parente323b1db4b0b4ef2b6783d4d7b5f15a640882614 (diff)
downloadrspamd-e85cbc442332876f48a4e0073f18bf821775a38e.tar.gz
rspamd-e85cbc442332876f48a4e0073f18bf821775a38e.zip
[Minor] Allow lua_text for opaque transition
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_worker.c20
1 files changed, 16 insertions, 4 deletions
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));
}