diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-09-19 12:08:48 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-09-19 12:08:48 +0100 |
commit | 19424515ec8b3dcb133cef30bf10f8c6b19cc3aa (patch) | |
tree | f38a63933f8164f0a39a60cf04f628d5eef52fcb /src/lua/lua_kann.c | |
parent | b5a184a0f8b376f3917f103b637a3db17925d2ae (diff) | |
download | rspamd-19424515ec8b3dcb133cef30bf10f8c6b19cc3aa.tar.gz rspamd-19424515ec8b3dcb133cef30bf10f8c6b19cc3aa.zip |
[Minor] Fix some leaks on error paths
Found by: coverity scan
Diffstat (limited to 'src/lua/lua_kann.c')
-rw-r--r-- | src/lua/lua_kann.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/lua/lua_kann.c b/src/lua/lua_kann.c index b5ddc55f2..9e37f3b0a 100644 --- a/src/lua/lua_kann.c +++ b/src/lua/lua_kann.c @@ -803,11 +803,11 @@ lua_kann_new_weight_conv1d (lua_State *L) static int lua_kann_new_leaf (lua_State *L) { - gint dim = luaL_checkinteger (L, 1), i, *ar; + int dim = luaL_checkinteger (L, 1), i, *ar; kad_node_t *t; if (dim >= 1 && dim < KAD_MAX_DIM && lua_istable (L, 2)) { - ar = g_malloc0 (sizeof (ar) * dim); + ar = g_new0 (int, dim); for (i = 0; i < dim; i ++) { lua_rawgeti (L, 2, i + 1); @@ -962,6 +962,10 @@ lua_kann_load (lua_State *L) t = lua_check_text (L, 1); + if (!t) { + return luaL_error (L, "invalid arguments"); + } + #ifndef HAVE_FMEMOPEN return luaL_error (L, "no support of loading from memory on your system"); #endif @@ -1043,7 +1047,7 @@ lua_kann_train1 (lua_State *L) } if (n_out <= 0) { - return luaL_error (L, "invalid outputs count: %d", n_in); + return luaL_error (L, "invalid outputs count: %d", n_out); } if (n != rspamd_lua_table_size (L, 3) || n == 0) { |