aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiecio Za <miecio@miecio.net>2019-03-18 20:38:23 +0100
committerMiecio Za <miecio@miecio.net>2019-03-18 20:38:23 +0100
commit925b1b072360e12f68a0992d3bdcb360c35f7663 (patch)
tree3f554277e6c06e6c97d06c952500b00959da06e8
parentcd08c8845f6ea0bac789ea8a49f7d8537f598b7d (diff)
downloadrspamd-925b1b072360e12f68a0992d3bdcb360c35f7663.tar.gz
rspamd-925b1b072360e12f68a0992d3bdcb360c35f7663.zip
[Minor] Fix leaks and hash usage for is_utf_outside_range
Fix memory leaks on checker errors and fix hash usage to use proper hash/compare functions
-rw-r--r--src/lua/lua_util.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lua/lua_util.c b/src/lua/lua_util.c
index 7c98a0989..0a1fc2010 100644
--- a/src/lua/lua_util.c
+++ b/src/lua/lua_util.c
@@ -2543,13 +2543,13 @@ lua_util_is_utf_outside_range(lua_State *L)
static rspamd_lru_hash_t *validators;
if (validators == NULL) {
- validators = rspamd_lru_hash_new(16, g_free, (GDestroyNotify)uspoof_close);
+ validators = rspamd_lru_hash_new_full(16, g_free, (GDestroyNotify)uspoof_close, g_int64_hash, g_int64_equal);
}
if (string_to_check) {
guint64 hash_key = (guint64)range_end << 32 || range_start;
- USpoofChecker *validator = rspamd_lru_hash_lookup(validators, &hash_key, time(NULL));
+ USpoofChecker *validator = rspamd_lru_hash_lookup(validators, &hash_key, 0);
UErrorCode uc_err = U_ZERO_ERROR;
@@ -2563,6 +2563,7 @@ lua_util_is_utf_outside_range(lua_State *L)
msg_err ("cannot init spoof checker: %s", u_errorName (uc_err));
lua_pushboolean (L, false);
uspoof_close(validator);
+ g_free(creation_hash_key);
return 1;
}
@@ -2579,10 +2580,11 @@ lua_util_is_utf_outside_range(lua_State *L)
msg_err ("Cannot configure uspoof: %s", u_errorName (uc_err));
lua_pushboolean (L, false);
uspoof_close(validator);
+ g_free(creation_hash_key);
return 1;
}
- rspamd_lru_hash_insert(validators, creation_hash_key, validator, time(NULL), 0);
+ rspamd_lru_hash_insert(validators, creation_hash_key, validator, 0, 0);
}
ret = uspoof_checkUTF8 (validator, string_to_check, len_of_string, NULL, &uc_err);