]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Correct some leaks in unit tests.
authorCorey Farrell <git@cfware.com>
Fri, 4 Aug 2017 02:30:12 +0000 (22:30 -0400)
committerCorey Farrell <git@cfware.com>
Fri, 4 Aug 2017 02:30:12 +0000 (22:30 -0400)
* chan_sip: channel in test_sip_rtpqos_1.
* test_config: config hook, config info and global config holder.
* test_core_format: format in format_attribute_set_without_interface.
* test_stream: unneeded frame duplication.
* test_taskprocessor: task_data.

Change-Id: I94d364d195cf3b3b5de2bf3ad565343275c7ad31

channels/sip/dialplan_functions.c
tests/test_config.c
tests/test_core_format.c
tests/test_taskprocessor.c

index 53d15dddb6dfc0327d077bd4fe0941f36ec8a18b..e74e57ecf376599d1ef96d1a2ce10e051c9e2c1a 100644 (file)
@@ -486,6 +486,9 @@ done:
                dialog_unlink_all(p);
                dialog_unref(p, "Destroy test object");
        }
+       if (chan) {
+               ast_channel_unref(chan);
+       }
        ast_rtp_engine_unregister(&test_engine);
        return res;
 }
index b4b38b81e46fb57e68b7e0d08580d4e4b6eb12df..2565ddb2fff023c2ead063522a1a88097a22ea38 100644 (file)
@@ -1040,6 +1040,7 @@ AST_TEST_DEFINE(config_hook)
        res = AST_TEST_PASS;
 
 out:
+       ast_config_hook_unregister("test_hook");
        delete_config_file();
        return res;
 }
@@ -1677,6 +1678,8 @@ AST_TEST_DEFINE(config_options_test)
        configs.codeccapopt = NULL;
        ast_string_field_free_memory(&defaults);
        ast_string_field_free_memory(&configs);
+       aco_info_destroy(&cfg_info);
+       ao2_global_obj_release(global_obj);
        return res;
 }
 
index 2140029726a0b41a250d2e1792a5239125bb74d1..b9ea1b14f8d2d2b540777348c17032056d7c101a 100644 (file)
@@ -860,6 +860,7 @@ AST_TEST_DEFINE(format_attribute_set_without_interface)
 {
        RAII_VAR(struct ast_codec *, codec, NULL, ao2_cleanup);
        RAII_VAR(struct ast_format *, format, NULL, ao2_cleanup);
+       struct ast_format *attr_set;
 
        switch (cmd) {
        case TEST_INIT:
@@ -885,10 +886,12 @@ AST_TEST_DEFINE(format_attribute_set_without_interface)
                return AST_TEST_FAIL;
        }
 
-       if (!ast_format_attribute_set(format, "bees", "cool")) {
+       attr_set = ast_format_attribute_set(format, "bees", "cool");
+       if (!attr_set) {
                ast_test_status_update(test, "Successfully set an attribute on a format without an interface\n");
                return AST_TEST_FAIL;
        }
+       ao2_cleanup(attr_set);
 
        return AST_TEST_PASS;
 }
index be48f92488f08af02bade50e7cb88fde1df2bb43..ad2074cb8d813c6d87bd71e9fc09eb881b1c2cdf 100644 (file)
@@ -677,7 +677,7 @@ AST_TEST_DEFINE(taskprocessor_push_local)
 {
        RAII_VAR(struct ast_taskprocessor *, tps, NULL,
                ast_taskprocessor_unreference);
-       struct task_data *task_data;
+       RAII_VAR(struct task_data *, task_data, NULL, ao2_cleanup);
        int local_data;
        int res;