]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix more init/deinit leaks
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jun 2018 16:26:22 +0000 (17:26 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jun 2018 16:26:22 +0000 (17:26 +0100)
src/libserver/cfg_utils.c
src/libutil/addr.c
src/lua/lua_map.c

index ef5d89ff6c1e5d6f995b895db6cb93efe17b8569..cf7f8d847e93b8094b542d17dcf77b6f3bd9e0a4 100644 (file)
@@ -1913,6 +1913,8 @@ rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
                                                        ucl_object_key (obj));
                                        return FALSE;
                                }
+
+                               return TRUE;
                        }
                        else {
                                /* Just a list */
@@ -1935,6 +1937,8 @@ rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
                                                EINVAL, "bad map object for %s", ucl_object_key (obj));
                                return FALSE;
                        }
+
+                       return TRUE;
                        break;
                case UCL_ARRAY:
                        /* List of IP addresses */
@@ -1961,6 +1965,11 @@ rspamd_config_radix_from_ucl (struct rspamd_config *cfg,
                }
        }
 
+       /* Destroy on cfg cleanup */
+       rspamd_mempool_add_destructor (cfg->cfg_pool,
+                       (rspamd_mempool_destruct_t)rspamd_map_helper_destroy_radix,
+                       *target);
+
        return TRUE;
 }
 
index dee5fbbb28ed102f03dad785470125d71b1c1821..a00d2a86b26fc1026248db05b362a9c01f54bb88 100644 (file)
@@ -1752,9 +1752,7 @@ rspamd_inet_library_init (void)
 void
 rspamd_inet_library_destroy (void)
 {
-       if (local_addrs != NULL) {
-               rspamd_map_helper_destroy_radix (local_addrs);
-       }
+       /* Ugly: local_addrs will actually be freed by config object */
 }
 
 gsize
index d5914706ce751b0ea86b867f9c1c51cff5b759f7..d3fc8edb9de75359bc545648e571bd39bbb0c2ec 100644 (file)
@@ -277,11 +277,13 @@ lua_config_radix_from_ucl (lua_State *L)
                        msg_err_config ("invalid radix map static");
                        lua_pushnil (L);
                        ucl_object_unref (fake_obj);
+                       ucl_object_unref (obj);
 
                        return 1;
                }
 
                ucl_object_unref (fake_obj);
+               ucl_object_unref (obj);
                pmap = lua_newuserdata (L, sizeof (void *));
                map->map = m;
                m->lua_map = map;