aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-03-13 15:01:18 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-03-13 15:01:55 +0000
commitf7aee39a9dc81ae437e1dcc651a7335a7ae071d3 (patch)
tree491a5422b5e32feabad05fca0cdb9ae196f731a5 /src/lua
parent376b5cac00888b7d3203f2c3e5611b0d25044c6b (diff)
downloadrspamd-f7aee39a9dc81ae437e1dcc651a7335a7ae071d3.tar.gz
rspamd-f7aee39a9dc81ae437e1dcc651a7335a7ae071d3.zip
[Fix] Fix various issues found by PVS Studio
https://www.viva64.com/
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_common.c4
-rw-r--r--src/lua/lua_config.c6
-rw-r--r--src/lua/lua_html.c3
-rw-r--r--src/lua/lua_http.c4
-rw-r--r--src/lua/lua_thread_pool.c2
-rw-r--r--src/lua/lua_util.c4
6 files changed, 16 insertions, 7 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 737455a3c..cff684aad 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -1940,7 +1940,6 @@ rspamd_lua_execute_lua_subprocess (lua_State *L,
msg_err ("call to subprocess failed: %v", tb);
/* Indicate error */
wlen = (1ULL << 63) + tb->len;
- g_string_free (tb, TRUE);
r = write (cbdata->sp[1], &wlen, sizeof (wlen));
if (r == -1) {
@@ -1951,6 +1950,7 @@ rspamd_lua_execute_lua_subprocess (lua_State *L,
if (r == -1) {
msg_err ("write failed: %s", strerror (errno));
}
+ g_string_free (tb, TRUE);
lua_pop (L, 1);
}
@@ -2205,9 +2205,9 @@ lua_worker_spawn_process (lua_State *L)
if (rspamd_socketpair (cbdata->sp, TRUE) == -1) {
msg_err ("cannot spawn socketpair: %s", strerror (errno));
- g_free (cbdata);
luaL_unref (L, LUA_REGISTRYINDEX, cbdata->func_cbref);
luaL_unref (L, LUA_REGISTRYINDEX, cbdata->cb_cbref);
+ g_free (cbdata);
return 0;
}
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index e846fd4d7..91c648e6f 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -3900,13 +3900,19 @@ lua_config_init_subsystem (lua_State *L)
cfg);
}
else {
+ g_strfreev (parts);
+
return luaL_error (L, "no event base specified");
}
}
else {
+ g_strfreev (parts);
+
return luaL_error (L, "invalid param: %s", parts[i]);
}
}
+
+ g_strfreev (parts);
}
else {
return luaL_error (L, "invalid arguments");
diff --git a/src/lua/lua_html.c b/src/lua/lua_html.c
index 63839c286..1b5828564 100644
--- a/src/lua/lua_html.c
+++ b/src/lua/lua_html.c
@@ -249,9 +249,6 @@ lua_html_has_property (lua_State *L)
else if (strcmp (propname, "unbalanced") == 0) {
ret = hc->flags & RSPAMD_HTML_FLAG_UNBALANCED;
}
- else if (strcmp (propname, "unbalanced") == 0) {
- ret = hc->flags & RSPAMD_HTML_FLAG_UNBALANCED;
- }
else if (strcmp (propname, "data_urls") == 0) {
ret = hc->flags & RSPAMD_HTML_FLAG_HAS_DATA_URLS;
}
diff --git a/src/lua/lua_http.c b/src/lua/lua_http.c
index 72eec70ad..e518e6dab 100644
--- a/src/lua/lua_http.c
+++ b/src/lua/lua_http.c
@@ -752,6 +752,10 @@ lua_http_request (lua_State *L)
rspamd_fstring_free (body);
}
+ if (mime_type) {
+ g_free (mime_type);
+ }
+
return luaL_error (L, "invalid body argument: %s",
lua_typename (L, lua_type (L, -1)));
}
diff --git a/src/lua/lua_thread_pool.c b/src/lua/lua_thread_pool.c
index ec9bfbe6f..d10f64579 100644
--- a/src/lua/lua_thread_pool.c
+++ b/src/lua/lua_thread_pool.c
@@ -305,7 +305,7 @@ lua_resume_thread_internal_full (struct thread_entry *thread_entry,
}
else {
tb = rspamd_lua_get_traceback_string (thread_entry->lua_state);
- if (thread_entry->error_callback) {
+ if (tb && thread_entry->error_callback) {
thread_entry->error_callback (thread_entry, ret, tb->str);
}
else if (thread_entry->task) {
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index d78e230e7..dad8c336b 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -1177,7 +1177,7 @@ lua_util_tokenize_text (lua_State *L)
{
LUA_TRACE_POINT;
const gchar *in = NULL;
- gsize len, pos, ex_len, i;
+ gsize len = 0, pos, ex_len, i;
GList *exceptions = NULL, *cur;
struct rspamd_lua_text *t;
struct rspamd_process_exception *ex;
@@ -2243,6 +2243,8 @@ lua_util_gzip_decompress (lua_State *L)
return luaL_error (L, "invalid arguments");
}
+ sz = t->len;
+
memset (&strm, 0, sizeof (strm));
/* windowBits +16 to decode gzip, zlib 1.2.0.4+ */
rc = inflateInit2 (&strm, MAX_WBITS + 16);