Skip to content
Snippets Groups Projects
Commit e744fa5f authored by Walter Doekes's avatar Walter Doekes
Browse files

Don't leak frames when memory is full in autoservice_run.

parent b3813c8b
No related branches found
No related tags found
No related merge requests found
......@@ -144,34 +144,40 @@ static void *autoservice_run(void *ign)
defer_frame = &hangup_frame;
} else if (ast_is_deferrable_frame(f)) {
defer_frame = f;
} else {
/* Can't defer. Discard and continue with next. */
ast_frfree(f);
continue;
}
if (defer_frame) {
for (i = 0; i < x; i++) {
struct ast_frame *dup_f;
for (i = 0; i < x; i++) {
struct ast_frame *dup_f;
if (mons[i] != chan) {
continue;
}
if (mons[i] != chan) {
continue;
}
if (defer_frame != f) {
if ((dup_f = ast_frdup(defer_frame))) {
AST_LIST_INSERT_HEAD(&ents[i]->deferred_frames, dup_f, frame_list);
}
} else {
if ((dup_f = ast_frisolate(defer_frame))) {
if (dup_f != defer_frame) {
ast_frfree(defer_frame);
}
AST_LIST_INSERT_HEAD(&ents[i]->deferred_frames, dup_f, frame_list);
}
if (!f) { /* defer_frame == &hangup_frame */
if ((dup_f = ast_frdup(defer_frame))) {
AST_LIST_INSERT_HEAD(&ents[i]->deferred_frames, dup_f, frame_list);
}
} else {
if ((dup_f = ast_frisolate(defer_frame))) {
AST_LIST_INSERT_HEAD(&ents[i]->deferred_frames, dup_f, frame_list);
}
if (dup_f != defer_frame) {
ast_frfree(defer_frame);
}
break;
}
} else if (f) {
ast_frfree(f);
break;
}
/* The ast_waitfor_n() call will only read frames from
* the channels' file descriptors. If ast_waitfor_n()
* returns non-NULL, then one of the channels in the
* mons array must have triggered the return. It's
* therefore impossible that we got here while (i >= x).
* If we did, we'd need to ast_frfree(f) if (f). */
}
if (callid) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment