diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-10-20 22:07:11 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-10-20 22:07:11 +0000 |
commit | 734d64af9e1770c4594dac5a5844c692ae08051d (patch) | |
tree | 05239e0dae857343059ac2914c2db7d23ab42095 /main | |
parent | 4b9838db9f32a31259c54ad120b74c546102ce95 (diff) |
Pay attention to the return value of the manipulate function.
While this looks like an optimization, it prevents a crash from occurring
when used with certain audiohook callbacks (diagnosed with SVN trunk,
backported to 1.4 to keep the source consistent across versions).
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@224855 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r-- | main/audiohook.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/main/audiohook.c b/main/audiohook.c index ec6f0f316..d501e73f4 100644 --- a/main/audiohook.c +++ b/main/audiohook.c @@ -586,7 +586,7 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st struct ast_frame *start_frame = frame, *middle_frame = frame, *end_frame = frame; struct ast_audiohook *audiohook = NULL; int samples = frame->samples; - + /* If the frame coming in is not signed linear we have to send it through the in_translate path */ if (frame->subclass != AST_FORMAT_SLINEAR) { if (in_translate->format != frame->subclass) { @@ -657,11 +657,17 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st continue; } /* Feed in frame to manipulation */ - audiohook->manipulate_callback(audiohook, chan, middle_frame, direction); + if (audiohook->manipulate_callback(audiohook, chan, middle_frame, direction)) { + /* Manipulation failed */ + ast_frfree(middle_frame); + middle_frame = NULL; + } ast_audiohook_unlock(audiohook); } AST_LIST_TRAVERSE_SAFE_END - end_frame = middle_frame; + if (middle_frame) { + end_frame = middle_frame; + } } /* Now we figure out what to do with our end frame (whether to transcode or not) */ @@ -689,7 +695,9 @@ static struct ast_frame *audio_audiohook_write_list(struct ast_channel *chan, st } } else { /* No frame was modified, we can just drop our middle frame and pass the frame we got in out */ - ast_frfree(middle_frame); + if (middle_frame) { + ast_frfree(middle_frame); + } } return end_frame; |