summaryrefslogtreecommitdiff
path: root/main/dial.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2015-09-22 17:08:49 -0500
committerRichard Mudgett <rmudgett@digium.com>2015-09-22 17:32:03 -0500
commit06f4f80a63092845a3e86fc827b025854beaf4b4 (patch)
treea2d1eb404f4823d509102daa3ab2cdce235bbafc /main/dial.c
parent069813db3c5f9fdd3d0c15c8237738c5bbf6d42a (diff)
app_page.c: Fix crash when forwarding with a predial handler.
Page uses the async method of dialing with the dial API. When a call gets forwarded there is no calling channel available. If the predial handler was set then the calling channel could not be put into auto-service for the forwarded call because it doesn't exist. A crash is the result. * Moved the callee predial parameter string processing to before the string is passed to the dial API rather than having the dial API do it. There are a few benefits do doing this. The first is the predial parameter string processing doesn't need to be done for each channel called by the dial API. The second is in async mode and the forwarded channel is to have the predial handler executed on it then the non-existent calling channel does not need to be present to process the predial parameter string. * Don't start auto-service on a non-existent calling channel to execute the predial handler when the dial API is in async mode and forwarding a call. ASTERISK-25384 #close Reported by: Chet Stevens Change-Id: If53892b286d29f6cf955e2545b03dcffa2610981
Diffstat (limited to 'main/dial.c')
-rw-r--r--main/dial.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/main/dial.c b/main/dial.c
index b935b6d8b..34d2f7055 100644
--- a/main/dial.c
+++ b/main/dial.c
@@ -378,14 +378,13 @@ static int begin_dial_prerun(struct ast_dial_channel *channel, struct ast_channe
ast_channel_unlock(channel->owner);
if (!ast_strlen_zero(predial_string)) {
- const char *predial_callee = ast_app_expand_sub_args(chan, predial_string);
- if (!predial_callee) {
- ast_log(LOG_ERROR, "Could not expand subroutine arguments in predial request '%s'\n", predial_string);
+ if (chan) {
+ ast_autoservice_start(chan);
+ }
+ ast_pre_call(channel->owner, predial_string);
+ if (chan) {
+ ast_autoservice_stop(chan);
}
- ast_autoservice_start(chan);
- ast_pre_call(channel->owner, predial_callee);
- ast_autoservice_stop(chan);
- ast_free((char *) predial_callee);
}
return 0;
@@ -397,10 +396,6 @@ int ast_dial_prerun(struct ast_dial *dial, struct ast_channel *chan, struct ast_
int res = -1;
char *predial_string = dial->options[AST_DIAL_OPTION_PREDIAL];
- if (!ast_strlen_zero(predial_string)) {
- ast_replace_subargument_delimiter(predial_string);
- }
-
AST_LIST_LOCK(&dial->channels);
AST_LIST_TRAVERSE(&dial->channels, channel, list) {
if ((res = begin_dial_prerun(channel, chan, cap, predial_string))) {
@@ -450,10 +445,6 @@ static int begin_dial(struct ast_dial *dial, struct ast_channel *chan, int async
int success = 0;
char *predial_string = dial->options[AST_DIAL_OPTION_PREDIAL];
- if (!ast_strlen_zero(predial_string)) {
- ast_replace_subargument_delimiter(predial_string);
- }
-
/* Iterate through channel list, requesting and calling each one */
AST_LIST_LOCK(&dial->channels);
AST_LIST_TRAVERSE(&dial->channels, channel, list) {
@@ -473,10 +464,6 @@ static int handle_call_forward(struct ast_dial *dial, struct ast_dial_channel *c
char *tech = "Local", *device = tmp, *stuff;
char *predial_string = dial->options[AST_DIAL_OPTION_PREDIAL];
- if (!ast_strlen_zero(predial_string)) {
- ast_replace_subargument_delimiter(predial_string);
- }
-
/* If call forwarding is disabled just drop the original channel and don't attempt to dial the new one */
if (FIND_RELATIVE_OPTION(dial, channel, AST_DIAL_OPTION_DISABLE_CALL_FORWARDING)) {
ast_hangup(original);