]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
memory leaks: Memory leak cleanup patch by Corey Farrell (first set)
authorJonathan Rose <jrose@digium.com>
Wed, 23 Oct 2013 19:55:05 +0000 (19:55 +0000)
committerJonathan Rose <jrose@digium.com>
Wed, 23 Oct 2013 19:55:05 +0000 (19:55 +0000)
(issue ASTERSIK-22467)
Reported by: Corey Farrell
Patches:
    chan_sip-parse_contact_header_test-free-contacts.patch uploaded by coreyfarrell (license 5909)
    cli-filename-completion-leak.patch uploaded by coreyfarrell (license 5909)
    func_math.patch uploaded by corefarrell (license 5909)
    main-test-cleanup.patch uploaded by coreyfarrell (license 5909)
    test_dlinklists.patch uploaded by coreyfarrell (license 5909)
........

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

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

channels/sip/reqresp_parser.c
funcs/func_math.c
main/editline/readline.c
main/test.c
tests/test_dlinklists.c

index 2d483353877b8d8d6d0efc9c8b1a78d6fe9760db..f96bb99c82874df5e95d22bb57ecec6aac06f096 100644 (file)
@@ -1562,6 +1562,10 @@ AST_TEST_DEFINE(parse_contact_header_test)
 
                                contactptr = AST_LIST_NEXT(contactptr,list);
                        }
+
+                       while ((contactptr = AST_LIST_REMOVE_HEAD(contactlistptr,list))) {
+                               ast_free(contactptr);
+                       }
                }
        }
 
index 05321b719ca3379170f8d090d2649c7e770d056c..36f3fc48a6848f32253900bee8e7d4b88e6c4175 100644 (file)
@@ -503,6 +503,9 @@ AST_TEST_DEFINE(test_MATH_function)
                res = AST_TEST_FAIL;
        }
 
+       ast_free(expr);
+       ast_free(result);
+
        return res;
 }
 #endif
index adf054d633d381134c1394478430af2b30d95b26..d202adbbd8b52ce20cc592bee79a7398216c57d0 100644 (file)
@@ -1236,8 +1236,11 @@ filename_completion_function(const char *text, int state)
        filename_len = strlen(filename);
 
        dir = opendir(dirname ? dirname : ".");
-       if (!dir)
+       if (!dir) {
+               free(filename);
+               free(dirname);
                return (NULL);  /* cannot open the directory */
+       }
 
        /* find the match */
        while ((entry = readdir(dir)) != NULL) {
@@ -1274,6 +1277,8 @@ filename_completion_function(const char *text, int state)
        } else
                temp = NULL;
        closedir(dir);
+       free(filename);
+       free(dirname);
 
        return (temp);
 }
index 16973ba1e79c01645b7c50af925e38a12ef5738c..1224b702d6f0992e0a03cc0e31a2076fd6b951f0 100644 (file)
@@ -931,6 +931,11 @@ int __ast_test_suite_assert_notify(const char *file, const char *func, int line,
        return 0;
 }
 
+static void test_shutdown(void)
+{
+       ast_cli_unregister_multiple(test_cli, ARRAY_LEN(test_cli));
+}
+
 #endif /* TEST_FRAMEWORK */
 
 int ast_test_init()
@@ -938,6 +943,7 @@ int ast_test_init()
 #ifdef TEST_FRAMEWORK
        /* Register cli commands */
        ast_cli_register_multiple(test_cli, ARRAY_LEN(test_cli));
+       ast_register_atexit(test_shutdown);
 #endif
 
        return 0;
index ec13851d79049496e1002f4e084c66a28404e5af..197dd757ab72b0d84e1450fba7dd4ba608483429 100644 (file)
@@ -337,6 +337,7 @@ static void dll_tests(void)
 
                if (e == b) {
                        AST_DLLIST_REMOVE_CURRENT(list);  /* C A */
+                       free(b);
                        print_list(tc, "C <=> A");
                }
                if (e == a) {
@@ -348,6 +349,7 @@ static void dll_tests(void)
        AST_DLLIST_TRAVERSE_SAFE_END;
        print_list(tc, "C <=> A <=> D");
 
+       destroy_test_container(tc);
 }
 
 static int unload_module(void)