aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_dial.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-10-09 18:13:57 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-10-09 18:13:57 +0000
commit16b21b562a8f785566bd59b042acafd7a929b63c (patch)
treee0eacf398370c64a24545cbefda31d38683b34eb /apps/app_dial.c
parent1bb56d7d53184f16e2f9602d4729531f888e1312 (diff)
Fix potential memory leaks.
ABE-1998 git-svn-id: http://svn.digium.com/svn/asterisk/trunk@223211 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_dial.c')
-rw-r--r--apps/app_dial.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 2e60df162..19e1148bc 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -582,6 +582,12 @@ struct chanlist {
static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str *featurecode);
+static void chanlist_free(struct chanlist *outgoing)
+{
+ ast_party_connected_line_free(&outgoing->connected);
+ ast_free(outgoing);
+}
+
static void hanguptree(struct chanlist *outgoing, struct ast_channel *exception, int answered_elsewhere)
{
/* Hang up a tree of stuff */
@@ -600,7 +606,7 @@ static void hanguptree(struct chanlist *outgoing, struct ast_channel *exception,
}
oo = outgoing;
outgoing = outgoing->next;
- ast_free(oo);
+ chanlist_free(oo);
}
}
@@ -1719,14 +1725,15 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
else {
if (!(datastore = ast_datastore_alloc(&dialed_interface_info, NULL))) {
ast_log(LOG_WARNING, "Unable to create channel datastore for dialed interfaces. Aborting!\n");
- ast_free(tmp);
+ chanlist_free(tmp);
goto out;
}
datastore->inheritance = DATASTORE_INHERIT_FOREVER;
if (!(dialed_interfaces = ast_calloc(1, sizeof(*dialed_interfaces)))) {
- ast_free(tmp);
+ ast_datastore_free(datastore);
+ chanlist_free(tmp);
goto out;
}
@@ -1750,7 +1757,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
if (di) {
fulldial++;
- ast_free(tmp);
+ chanlist_free(tmp);
continue;
}
@@ -1761,7 +1768,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
if (strcasecmp(tech, "Local")) {
if (!(di = ast_calloc(1, sizeof(*di) + strlen(interface)))) {
AST_LIST_UNLOCK(dialed_interfaces);
- ast_free(tmp);
+ chanlist_free(tmp);
goto out;
}
strcpy(di->interface, interface);
@@ -1779,7 +1786,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
handle_cause(cause, &num);
if (!rest) /* we are on the last destination */
chan->hangupcause = cause;
- ast_free(tmp);
+ chanlist_free(tmp);
continue;
}
pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", numsubst);
@@ -1868,7 +1875,7 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
ast_channel_unlock(chan);
ast_hangup(tc);
tc = NULL;
- ast_free(tmp);
+ chanlist_free(tmp);
continue;
} else {
const char *tmpexten = ast_strdupa(S_OR(chan->macroexten, chan->exten));