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
This commit is contained in:
Jonathan Rose
2013-05-28 17:35:12 +00:00
parent f318fa2c50
commit 51a6491c30

View File

@@ -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;