aboutsummaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-01 19:34:49 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2005-09-01 19:34:49 +0000
commitf24fbc3714521f256483f7777ae5bbaabedb7455 (patch)
tree133ad2a6a39d4c96fe725244660bd2a1851dea97 /res
parentd6d95933f0ed40461173549261f618150045be1f (diff)
don't access freed memory if the frame was malloc'd
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@6484 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res')
-rwxr-xr-xres/res_musiconhold.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index a964717d6..540b9efe2 100755
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -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 ast_frame *f = NULL;
int res = 0;
+
state->sample_queue += samples;
while (state->sample_queue > 0) {
if ((f = moh_files_readframe(chan))) {
state->samples += f->samples;
res = ast_write(chan, f);
+ state->sample_queue -= f->samples;
ast_frfree(f);
if (res < 0) {
ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", chan->name, strerror(errno));
return -1;
}
- state->sample_queue -= f->samples;
} else
return -1;
}