]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix various memory leaks
authorKevin Harwell <kharwell@digium.com>
Fri, 30 Aug 2013 19:16:20 +0000 (19:16 +0000)
committerKevin Harwell <kharwell@digium.com>
Fri, 30 Aug 2013 19:16:20 +0000 (19:16 +0000)
main/config.c - cleanup cache fie includes
res/res_security_log.c - unregister logger level
channesl/chan_sip.c - cleanup io context and notify_types
main/translator.c - cleanup at shutdown
main/named_acl.c - cleanup cli commands
main/indications.c - ast_get_indication_tone() unref default_tone_zone if used

(closes issues ASTERISK-22378)
Reported by: Corey Farrell
Patches:
     config_shutdown.patch uploaded by coreyfarrell (license 5909)
     res_security_log.patch uploaded by coreyfarrell (license 5909)
     chan_sip-11.patch uploaded by coreyfarrell (license 5909)
     indications_refleak.patch uploaded by coreyfarrell (license 5909)
     named_acl-cli_unreg-11.patch uploaded by coreyfarrell (license 5909)
     translate_shutdown.patch uploaded by coreyfarrell (license 5909)

........

Merged revisions 398102 from http://svn.asterisk.org/svn/asterisk/branches/1.8

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@398103 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_sip.c
main/config.c
main/indications.c
main/named_acl.c
main/translate.c
res/res_security_log.c

index 49f2a3867a32e183e61f45a07213b2201f6dadf6..db48ca1d8369c440b12718d1c678536c295e51ab 100644 (file)
@@ -34717,7 +34717,12 @@ static int unload_module(void)
 
        clear_sip_domains();
        sip_cfg.contact_acl = ast_free_acl_list(sip_cfg.contact_acl);
+       if (sipsock_read_id) {
+               ast_io_remove(io, sipsock_read_id);
+               sipsock_read_id = NULL;
+       }
        close(sipsock);
+       io_context_destroy(io);
        ast_sched_context_destroy(sched);
        con = ast_context_find(used_context);
        if (con) {
@@ -34731,6 +34736,11 @@ static int unload_module(void)
        sip_reqresp_parser_exit();
        sip_unregister_tests();
 
+       if (notify_types) {
+               ast_config_destroy(notify_types);
+               notify_types = NULL;
+       }
+
        ast_format_cap_destroy(sip_tech.capabilities);
        sip_cfg.caps = ast_format_cap_destroy(sip_cfg.caps);
 
index fbfbb7e5819e4da5d7c45d1e8be9bed0edae1562..6b50b7022304daf62654930879365af73e18293e 100644 (file)
@@ -3164,6 +3164,10 @@ static void config_shutdown(void)
 
        AST_LIST_LOCK(&cfmtime_head);
        while ((cfmtime = AST_LIST_REMOVE_HEAD(&cfmtime_head, list))) {
+               struct cache_file_include *cfinclude;
+               while ((cfinclude = AST_LIST_REMOVE_HEAD(&cfmtime->includes, list))) {
+                       ast_free(cfinclude);
+               }
                ast_free(cfmtime);
        }
        AST_LIST_UNLOCK(&cfmtime_head);
index 6ad30bfcf5a298ee7330351e8231bdd284e3bf46..bd1df8f8c8294f1abb0789bd5bd51871bd0a83a5 100644 (file)
@@ -499,6 +499,9 @@ struct ast_tone_zone_sound *ast_get_indication_tone(const struct ast_tone_zone *
 
        ast_tone_zone_unlock(zone);
 
+       if (!_zone)
+               zone = ast_tone_zone_unref(zone);
+
        return ts;
 }
 
index 2ec2d7045dd311cbcf51cbc51701e36b92676d61..9f4a0e60ec0f052186ee67308c96d3e9c797f30b 100644 (file)
@@ -557,6 +557,8 @@ static struct ast_cli_entry cli_named_acl[] = {
 
 static void named_acl_cleanup(void)
 {
+       ast_cli_unregister_multiple(cli_named_acl, ARRAY_LEN(cli_named_acl));
+
        aco_info_destroy(&cfg_info);
        ao2_global_obj_release(globals);
 }
index ce430ce9777bb47c750712f359f10fec59e96758..a258599d2215a29936f25bdea79f305e918c46ee 100644 (file)
@@ -1396,11 +1396,27 @@ void ast_translate_available_formats(struct ast_format_cap *dest, struct ast_for
        ast_format_cap_iter_end(src);
 }
 
+static void translate_shutdown(void)
+{
+       int x;
+       ast_cli_unregister_multiple(cli_translate, ARRAY_LEN(cli_translate));
+
+       ast_rwlock_wrlock(&tablelock);
+       for (x = 0; x < index_size; x++) {
+               ast_free(__matrix[x]);
+       }
+       ast_free(__matrix);
+       ast_free(__indextable);
+       ast_rwlock_unlock(&tablelock);
+       ast_rwlock_destroy(&tablelock);
+}
+
 int ast_translate_init(void)
 {
        int res = 0;
        ast_rwlock_init(&tablelock);
        res = matrix_resize(1);
        res |= ast_cli_register_multiple(cli_translate, ARRAY_LEN(cli_translate));
+       ast_register_atexit(translate_shutdown);
        return res;
 }
index 3e8c48a24e73aed53db221b91cad7d5ae2d8cf78..8611e3f592a40ae0d9726420489681c27f59eae9 100644 (file)
@@ -159,6 +159,8 @@ static int unload_module(void)
                security_event_sub = ast_event_unsubscribe(security_event_sub);
        }
 
+       ast_logger_unregister_level(LOG_SECURITY_NAME);
+
        ast_verb(3, "Security Logging Disabled\n");
 
        return 0;