Author: wdoekes Date: Fri Aug 9 15:29:09 2013 New Revision: 396505 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=396505 Log: Don't leak frames when memory is full in autoservice_run.
Review: https://reviewboard.asterisk.org/r/2566/ Modified: trunk/main/autoservice.c Modified: trunk/main/autoservice.c URL: http://svnview.digium.com/svn/asterisk/trunk/main/autoservice.c?view=diff&rev=396505&r1=396504&r2=396505 ============================================================================== --- trunk/main/autoservice.c (original) +++ trunk/main/autoservice.c Fri Aug 9 15:29:09 2013 @@ -144,34 +144,40 @@ defer_frame = &hangup_frame; } else if (ast_is_deferrable_frame(f)) { defer_frame = f; - } - - if (defer_frame) { - for (i = 0; i < x; i++) { - struct ast_frame *dup_f; - - if (mons[i] != chan) { - continue; + } else { + /* Can't defer. Discard and continue with next. */ + ast_frfree(f); + continue; + } + + for (i = 0; i < x; i++) { + struct ast_frame *dup_f; + + if (mons[i] != chan) { + continue; + } + + 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); } - - 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); - } + } else { + if ((dup_f = ast_frisolate(defer_frame))) { + AST_LIST_INSERT_HEAD(&ents[i]->deferred_frames, dup_f, frame_list); } - - break; + if (dup_f != defer_frame) { + ast_frfree(defer_frame); + } } - } 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) { -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits
