Author: coreyfarrell Date: Sun Nov 2 02:13:52 2014 New Revision: 427027 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=427027 Log: Fix ast_writestream leaks
Fix cleanup in __ast_play_and_record where others[x] may be leaked. This was caught where prepend != NULL && outmsg != NULL, once realfile[x] == NULL any further others[x] would be leaked. A cleanup block was also added for prepend != NULL && outmsg == NULL. 11+: Fix leak of ast_writestream recording_fs in app_voicemail:leave_voicemail. ASTERISK-24476 #close Reported by: Corey Farrell Review: https://reviewboard.asterisk.org/r/4138/ ........ Merged revisions 427023 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 427024 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 427025 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 427026 from http://svn.asterisk.org/svn/asterisk/branches/13 Modified: trunk/ (props changed) trunk/apps/app_voicemail.c trunk/main/app.c Propchange: trunk/ ------------------------------------------------------------------------------ Binary property 'branch-13-merged' - no diff available. Modified: trunk/apps/app_voicemail.c URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=427027&r1=427026&r2=427027 ============================================================================== --- trunk/apps/app_voicemail.c (original) +++ trunk/apps/app_voicemail.c Sun Nov 2 02:13:52 2014 @@ -6158,6 +6158,7 @@ ast_log(LOG_ERROR,"Unable to determine sample rate of recording %s\n", recdata->recording_file); } } + ast_closeframe(recording_fs); } /* If the duration was below the minimum duration for the user, let's just drop the whole thing now */ Modified: trunk/main/app.c URL: http://svnview.digium.com/svn/asterisk/trunk/main/app.c?view=diff&rev=427027&r1=427026&r2=427027 ============================================================================== --- trunk/main/app.c (original) +++ trunk/main/app.c Sun Nov 2 02:13:52 2014 @@ -1782,17 +1782,19 @@ ast_truncstream(others[x]); ast_closestream(others[x]); } - } - - if (prepend && outmsg) { + } else if (prepend && outmsg) { struct ast_filestream *realfiles[AST_MAX_FORMATS]; struct ast_frame *fr; for (x = 0; x < fmtcnt; x++) { snprintf(comment, sizeof(comment), "Opening the real file %s.%s\n", recordfile, sfmt[x]); realfiles[x] = ast_readfile(recordfile, sfmt[x], comment, O_RDONLY, 0, 0); - if (!others[x] || !realfiles[x]) { + if (!others[x]) { break; + } + if (!realfiles[x]) { + ast_closestream(others[0]); + continue; } /*!\note Same logic as above. */ if (dspsilence) { @@ -1810,7 +1812,15 @@ ast_verb(4, "Recording Format: sfmts=%s, prependfile %s, recordfile %s\n", sfmt[x], prependfile, recordfile); ast_filedelete(prependfile, sfmt[x]); } - } + } else { + for (x = 0; x < fmtcnt; x++) { + if (!others[x]) { + break; + } + ast_closestream(others[x]); + } + } + if (rfmt && ast_set_read_format(chan, rfmt)) { ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_format_get_name(rfmt), ast_channel_name(chan)); } -- _____________________________________________________________________ -- 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
