summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Rose <jrose@digium.com>2013-10-24 17:00:27 +0000
committerJonathan Rose <jrose@digium.com>2013-10-24 17:00:27 +0000
commit4ca0f222e85554e24d5cfb7d48b3a774d96a6e45 (patch)
tree411b1a8a88241acde89163243e464edce21486d4
parentbeb5cdbef54908cc1564539f9cfb8852b530f2bc (diff)
memory leaks: Memory leak cleanup patch by Corey Farrell (second set)
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) ........ Merged revisions 401704 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 401705 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 401706 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@401707 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--channels/chan_dahdi.c7
-rw-r--r--codecs/ilbc/doCPLC.c2
-rw-r--r--main/app.c4
-rw-r--r--main/asterisk.c6
-rw-r--r--main/data.c3
-rw-r--r--utils/clicompat.c10
6 files changed, 28 insertions, 4 deletions
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index cc82f156f..b68299478 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -11155,6 +11155,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;
@@ -11178,6 +11183,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);
@@ -11433,6 +11439,7 @@ static void *do_monitor(void *data)
ast_mutex_unlock(&iflock);
}
/* Never reached */
+ pthread_cleanup_pop(1);
return NULL;
}
diff --git a/codecs/ilbc/doCPLC.c b/codecs/ilbc/doCPLC.c
index adbfac71a..9fa4584fe 100644
--- a/codecs/ilbc/doCPLC.c
+++ b/codecs/ilbc/doCPLC.c
@@ -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;
diff --git a/main/app.c b/main/app.c
index 69e312de9..6f70b2101 100644
--- a/main/app.c
+++ b/main/app.c
@@ -2786,7 +2786,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) {
diff --git a/main/asterisk.c b/main/asterisk.c
index 95355e42f..2e5ffa729 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -1975,11 +1975,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;
diff --git a/main/data.c b/main/data.c
index 73a336613..af4abd902 100644
--- a/main/data.c
+++ b/main/data.c
@@ -3313,6 +3313,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)
@@ -3330,9 +3331,7 @@ int ast_data_init(void)
res |= ast_manager_register_xml_core("DataGet", 0, manager_data_get);
-#ifdef TEST_FRAMEWORK
AST_TEST_REGISTER(test_data_get);
-#endif
ast_register_atexit(data_shutdown);
diff --git a/utils/clicompat.c b/utils/clicompat.c
index 33f90fae1..d46ed897d 100644
--- a/utils/clicompat.c
+++ b/utils/clicompat.c
@@ -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;
+}