aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-26 17:26:33 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-26 17:26:33 +0000
commit5f45749d11981db96788bc496804eb29d61756fc (patch)
tree991acd51cba21485aeb235a53ab768463571a65b
parent55aafe42d8fde7bf32c0830496a35a487dc00253 (diff)
downloadrspamd-5f45749d11981db96788bc496804eb29d61756fc.tar.gz
rspamd-5f45749d11981db96788bc496804eb29d61756fc.zip
Steal lua_text ownership to prevent gc
-rw-r--r--src/lua/lua_tcp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c
index 86a6bf723..93050eb2d 100644
--- a/src/lua/lua_tcp.c
+++ b/src/lua/lua_tcp.c
@@ -177,6 +177,7 @@ lua_tcp_write_helper (struct lua_tcp_cbdata *cbd)
/* We know that niov is small enough for that */
cur_iov = alloca (niov * sizeof (struct iovec));
memcpy (cur_iov, cbd->iov, niov * sizeof (struct iovec));
+
for (i = 0; i < cbd->iovlen && remain > 0; i++) {
/* Find out the first iov required */
start = &cur_iov[i];
@@ -368,6 +369,12 @@ lua_tcp_arg_toiovec (lua_State *L, gint pos, rspamd_mempool_t *pool,
if (t) {
vec->iov_base = (void *)t->start;
vec->iov_len = t->len;
+
+ if (t->own) {
+ /* Steal ownership */
+ t->own = FALSE;
+ rspamd_mempool_add_destructor (pool, g_free, (void *)t->start);
+ }
}
else {
return FALSE;