aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjrose <jrose@f38db490-d61c-443f-a65b-d21fe96a405b>2011-03-14 13:12:51 +0000
committerjrose <jrose@f38db490-d61c-443f-a65b-d21fe96a405b>2011-03-14 13:12:51 +0000
commit3a29319f688f8ed7fe4fd916289cb7b125edd2a5 (patch)
treef2c31d9f90a7904f7f8fd87d6bc64afca215ccb8
parentb760c34658c0cfee7a665647b8f9eae7fc9f4b9a (diff)
Fixes null reference bug introduced by audio hook changes that affects various OS distributions. Thanks David.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@310547 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/audiohook.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/main/audiohook.c b/main/audiohook.c
index bb510e333..a1d658ce7 100644
--- a/main/audiohook.c
+++ b/main/audiohook.c
@@ -311,25 +311,26 @@ static struct ast_frame *audiohook_read_frame_both(struct ast_audiohook *audioho
ast_debug(1, "Failed to get %d samples from write factory %p\n", (int)samples, &audiohook->write_factory);
/* Basically we figure out which buffer to use... and if mixing can be done here */
- if (!read_buf && !write_buf)
- return NULL;
-
- if (read_buf) {
- final_buf = buf1;
- frame.data.ptr = final_buf;
+ if (read_buf && read_reference) {
+ frame.data.ptr = buf1;
*read_reference = ast_frdup(&frame);
}
-
- if (write_buf) {
- final_buf = buf2;
- frame.data.ptr = final_buf;
+ if (write_buf && write_reference) {
+ frame.data.ptr = buf2;
*write_reference = ast_frdup(&frame);
}
if (read_buf && write_buf) {
- for (i = 0, data1 = read_buf, data2 = write_buf; i < samples; i++, data1++, data2++)
+ for (i = 0, data1 = read_buf, data2 = write_buf; i < samples; i++, data1++, data2++) {
ast_slinear_saturated_add(data1, data2);
+ }
+ final_buf = buf1;
+ } else if (read_buf) {
final_buf = buf1;
+ } else if (write_buf) {
+ final_buf = buf2;
+ } else {
+ return NULL;
}
/* Make the final buffer part of the frame, so it gets duplicated fine */