diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-07-20 19:24:29 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-07-20 19:24:29 +0100 |
commit | c90ebed0c331c71f57eda2d2dcf092e95cdaae45 (patch) | |
tree | bbf73ed04b166a0dcb15d7c42ea89802fffaf34f /src/lua/lua_map.c | |
parent | 0bfac24ffc06be3a6eb1fbbea41447ba7c89e136 (diff) | |
download | rspamd-c90ebed0c331c71f57eda2d2dcf092e95cdaae45.tar.gz rspamd-c90ebed0c331c71f57eda2d2dcf092e95cdaae45.zip |
[Fix] Do not abort when cannot load a map
Diffstat (limited to 'src/lua/lua_map.c')
-rw-r--r-- | src/lua/lua_map.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/lua/lua_map.c b/src/lua/lua_map.c index bd5dbbc36..ba7d49149 100644 --- a/src/lua/lua_map.c +++ b/src/lua/lua_map.c @@ -536,30 +536,32 @@ lua_map_get_key (lua_State * L) } } - if (addr != NULL) { - if (radix_find_compressed_addr (radix, addr->addr) - != RADIX_NO_VALUE) { - ret = TRUE; + if (radix) { + if (addr != NULL) { + if (radix_find_compressed_addr (radix, addr->addr) + != RADIX_NO_VALUE) { + ret = TRUE; + } } - } - else if (key_num != 0) { - if (radix_find_compressed (radix, (guint8 *)&key_num, sizeof (key_num)) - != RADIX_NO_VALUE) { - ret = TRUE; + else if (key_num != 0) { + if (radix_find_compressed (radix, (guint8 *)&key_num, sizeof (key_num)) + != RADIX_NO_VALUE) { + ret = TRUE; + } } } } else if (map->type == RSPAMD_LUA_MAP_SET) { key = lua_map_process_string_key (L, 2, &len); - if (key) { + if (key && map->data.hash) { ret = g_hash_table_lookup (map->data.hash, key) != NULL; } } else if (map->type == RSPAMD_LUA_MAP_REGEXP) { key = lua_map_process_string_key (L, 2, &len); - if (key) { + if (key && map->data.re_map) { value = rspamd_match_regexp_map (map->data.re_map, key, len); if (value) { @@ -572,7 +574,7 @@ lua_map_get_key (lua_State * L) /* key-value map */ key = lua_map_process_string_key (L, 2, &len); - if (key) { + if (key && map->data.hash) { value = g_hash_table_lookup (map->data.hash, key); } |