mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-23 13:09:00 +00:00
don't access freed memory if the frame was malloc'd
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6484 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -241,18 +241,19 @@ static int moh_files_generator(struct ast_channel *chan, void *data, int len, in
|
|||||||
struct moh_files_state *state = chan->music_state;
|
struct moh_files_state *state = chan->music_state;
|
||||||
struct ast_frame *f = NULL;
|
struct ast_frame *f = NULL;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
state->sample_queue += samples;
|
state->sample_queue += samples;
|
||||||
|
|
||||||
while (state->sample_queue > 0) {
|
while (state->sample_queue > 0) {
|
||||||
if ((f = moh_files_readframe(chan))) {
|
if ((f = moh_files_readframe(chan))) {
|
||||||
state->samples += f->samples;
|
state->samples += f->samples;
|
||||||
res = ast_write(chan, f);
|
res = ast_write(chan, f);
|
||||||
|
state->sample_queue -= f->samples;
|
||||||
ast_frfree(f);
|
ast_frfree(f);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", chan->name, strerror(errno));
|
ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", chan->name, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
state->sample_queue -= f->samples;
|
|
||||||
} else
|
} else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user