summaryrefslogtreecommitdiff
path: root/apps/app_externalivr.c
diff options
context:
space:
mode:
authorSean Bright <sean@malleable.com>2012-04-19 16:10:04 +0000
committerSean Bright <sean@malleable.com>2012-04-19 16:10:04 +0000
commitba93541cedf29837f8fe485ebb3a5a2c06499693 (patch)
tree4cac94280844f5d32697976260351688277c53b9 /apps/app_externalivr.c
parent772ad8a641f281b81bfab9a118f6cfb1a3b4b4c4 (diff)
Prevent a crash in ExternalIVR when the 'S' command is sent first.
If the first command sent from an ExternalIVR client is an 'S' command, we were blindly removing the first element from the play list and deferencing it, even if it was NULL. This corrects that and also locks appropriately in one place. (issue ASTERISK-17889) Reported by: Chris Maciejewski ........ Merged revisions 362586 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 362587 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@362588 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_externalivr.c')
-rw-r--r--apps/app_externalivr.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/apps/app_externalivr.c b/apps/app_externalivr.c
index d9aaf67a9..164118102 100644
--- a/apps/app_externalivr.c
+++ b/apps/app_externalivr.c
@@ -683,13 +683,14 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
if (f->frametype == AST_FRAME_DTMF) {
send_eivr_event(eivr_events, f->subclass.integer, NULL, chan);
if (u->option_autoclear) {
+ AST_LIST_LOCK(&u->playlist);
if (!u->abort_current_sound && !u->playing_silence) {
/* send interrupted file as T data */
- entry = AST_LIST_REMOVE_HEAD(&u->playlist, list);
- send_eivr_event(eivr_events, 'T', entry->filename, chan);
- ast_free(entry);
+ if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
+ send_eivr_event(eivr_events, 'T', entry->filename, chan);
+ ast_free(entry);
+ }
}
- AST_LIST_LOCK(&u->playlist);
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan);
ast_free(entry);
@@ -768,9 +769,10 @@ static int eivr_comm(struct ast_channel *chan, struct ivr_localuser *u,
AST_LIST_LOCK(&u->playlist);
if (!u->abort_current_sound && !u->playing_silence) {
/* send interrupted file as T data */
- entry = AST_LIST_REMOVE_HEAD(&u->playlist, list);
- send_eivr_event(eivr_events, 'T', entry->filename, chan);
- ast_free(entry);
+ if ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
+ send_eivr_event(eivr_events, 'T', entry->filename, chan);
+ ast_free(entry);
+ }
}
while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list))) {
send_eivr_event(eivr_events, 'D', entry->filename, chan);