From 51a6491c30e784034da376a41c52d6f6cf77f16a Mon Sep 17 00:00:00 2001 From: Jonathan Rose Date: Tue, 28 May 2013 17:35:12 +0000 Subject: [PATCH] Fix a memory copying bug in slinfactory which was causing mixmonitor issues. Reported by: Michael Walton Tested by: Jonathan Rose Patches: slinfactory.c.ASTERISK-21799.patch uploaded by Michael Walton (license 6502) (closes issue ASTERISK-21799) git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@389895 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/slinfactory.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/main/slinfactory.c b/main/slinfactory.c index e18230a54f..7fd2462a3f 100644 --- a/main/slinfactory.c +++ b/main/slinfactory.c @@ -139,7 +139,7 @@ int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f) return x; } -int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples) +int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples) { struct ast_frame *frame_ptr; unsigned int sofar = 0, ineed, remain; @@ -150,7 +150,7 @@ int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples) if (sf->holdlen) { if (sf->holdlen <= ineed) { - memcpy(offset, sf->hold, sf->holdlen * sizeof(*offset)); + memcpy(offset, sf->offset, sf->holdlen * sizeof(*offset)); sofar += sf->holdlen; offset += sf->holdlen; sf->holdlen = 0; @@ -164,10 +164,10 @@ int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples) } continue; } - + if ((frame_ptr = AST_LIST_REMOVE_HEAD(&sf->queue, frame_list))) { frame_data = frame_ptr->data.ptr; - + if (frame_ptr->samples <= ineed) { memcpy(offset, frame_data, frame_ptr->samples * sizeof(*offset)); sofar += frame_ptr->samples;