]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
memory leaks: Memory leak cleanup patch by Corey Farrell (second set)
authorJonathan Rose <jrose@digium.com>
Thu, 24 Oct 2013 16:39:48 +0000 (16:39 +0000)
committerJonathan Rose <jrose@digium.com>
Thu, 24 Oct 2013 16:39:48 +0000 (16:39 +0000)
Also covers ast_app_parse_timelen-fail-zero-length.patch, but the patch was
replaced with one of my own.

(issue ASTERISK-22467)
Reported by: Corey Farrell
Patches:
    chan_dahdi-cleanup_push.patch uploaded by coreyfarrell (license 5909)
    clicompat-r2.patch uploaded by coreyfarrell (license 5909)
    codecs-ilbc-doCPLC.patch uploaded by coreyfarrell (license 5909)
    data-cleanup-test-registration.patch uploaded by coreyfarrell (license 5909)
    main-asterisk-kill-listener.patch uploaded by coreyfarrell (license 5909)

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

channels/chan_dahdi.c
codecs/ilbc/doCPLC.c
main/app.c
main/asterisk.c
main/data.c
utils/clicompat.c

index c145bf96314e2eeb5ddc2a0d40b1bbd3edd8bf37..4b5f0310e92e3867b7789d4e2256dba7231a3028 100644 (file)
@@ -11709,6 +11709,11 @@ static struct dahdi_pvt *handle_init_event(struct dahdi_pvt *i, int event)
        return NULL;
 }
 
+static void monitor_pfds_clean(void *arg) {
+       struct pollfd **pfds = arg;
+       ast_free(*pfds);
+}
+
 static void *do_monitor(void *data)
 {
        int count, res, res2, spoint, pollres=0;
@@ -11732,6 +11737,7 @@ static void *do_monitor(void *data)
 #endif
        pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
 
+       pthread_cleanup_push(monitor_pfds_clean, &pfds);
        for (;;) {
                /* Lock the interface list */
                ast_mutex_lock(&iflock);
@@ -11988,6 +11994,7 @@ static void *do_monitor(void *data)
                ast_mutex_unlock(&iflock);
        }
        /* Never reached */
+       pthread_cleanup_pop(1);
        return NULL;
 
 }
index adbfac71a2404ef421035d4b037e27f4b191b4c7..9fa4584fe8dee53efca3d398a936c573a9d10070 100644 (file)
@@ -90,7 +90,7 @@
        int lag=20, randlag;
        float gain, maxcc;
        float use_gain;
-       float gain_comp, maxcc_comp, per, max_per;
+       float gain_comp, maxcc_comp, per, max_per=0;
        int i, pick, use_lag;
        float ftmp, randvec[BLOCKL_MAX], pitchfact, energy;
 
index 0a14b4dda16074e057f6dd31b4f1ba54d35329c0..8bb03f0cb11a8a34c2b71aaaf33db63a143109dd 100644 (file)
@@ -2196,7 +2196,9 @@ int ast_app_parse_timelen(const char *timestr, int *result, enum ast_timelen uni
                return -1;
        }
 
-       if ((res = sscanf(timestr, FMT, &amount, u)) == 0) {
+       res = sscanf(timestr, FMT, &amount, u);
+
+       if (res == 0 || res == EOF) {
 #undef FMT
                return -1;
        } else if (res == 2) {
index 092241b27f6cb01b5fefa106c216f42999534c52..fe4088b541b0549b5e68ee79a171013d47859ad1 100644 (file)
@@ -1800,11 +1800,17 @@ static void really_quit(int num, shutdown_nice_t niceness, int restart)
                close(ast_socket);
                ast_socket = -1;
                unlink(ast_config_AST_SOCKET);
+               pthread_kill(lthread, SIGURG);
+               pthread_join(lthread, NULL);
        }
        if (ast_consock > -1)
                close(ast_consock);
        if (!ast_opt_remote)
                unlink(ast_config_AST_PID);
+       if (sig_alert_pipe[0])
+               close(sig_alert_pipe[0]);
+       if (sig_alert_pipe[1])
+               close(sig_alert_pipe[1]);
        printf("%s", term_quit());
        if (restart) {
                int i;
index 9bf1cab267c27392de78bf01ab23f45039712aac..020e2ca66ccb887152fd678dd6c4afa414a96391 100644 (file)
@@ -3290,6 +3290,7 @@ static void data_shutdown(void)
        ao2_t_ref(root_data.container, -1, "Unref root_data.container in data_shutdown");
        root_data.container = NULL;
        ast_rwlock_destroy(&root_data.lock);
+       AST_TEST_UNREGISTER(test_data_get);
 }
 
 int ast_data_init(void)
@@ -3307,9 +3308,7 @@ int ast_data_init(void)
 
        res |= ast_manager_register_xml("DataGet", 0, manager_data_get);
 
-#ifdef TEST_FRAMEWORK
        AST_TEST_REGISTER(test_data_get);
-#endif
 
        ast_register_atexit(data_shutdown);
 
index 33f90fae167b2eb9561000de71e4e69e3cff8b1c..d46ed897d77e9d58e2cb6ab71b723d0477928e37 100644 (file)
@@ -9,8 +9,18 @@ void ast_cli(int fd, const char *fmt, ...)
 
 struct ast_cli_entry;
 
+int ast_register_atexit(void (*func)(void));
+int ast_register_atexit(void (*func)(void))
+{
+       return 0;
+}
 int ast_cli_register_multiple(struct ast_cli_entry *e, int len);
 int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
 {
        return 0;
 }
+int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len);
+int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
+{
+       return 0;
+}