[Asterisk-code-review] format ogg vorbis: Clear ogg/vorbis data structures on close (asterisk[master])

Joshua Colp asteriskteam at digium.com
Wed Apr 19 08:38:17 CDT 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/5477 )

Change subject: format_ogg_vorbis: Clear ogg/vorbis data structures on close
......................................................................


format_ogg_vorbis: Clear ogg/vorbis data structures on close

On filestream close, we need to clear out the ogg & vorbis data
structures to prevent a memory leak.

ASTERISK-26169 #close
Reported by: Ivan Myalkin

Change-Id: Iee94c5a5d5bdafbf8b181c5c064d15d90ace8274
---
M formats/format_ogg_vorbis.c
1 file changed, 8 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/formats/format_ogg_vorbis.c b/formats/format_ogg_vorbis.c
index d4212a1..c0f8c19 100644
--- a/formats/format_ogg_vorbis.c
+++ b/formats/format_ogg_vorbis.c
@@ -158,6 +158,7 @@
 
 	if (vorbis_encode_init_vbr(&tmp->vi, 1, DEFAULT_SAMPLE_RATE, 0.4)) {
 		ast_log(LOG_ERROR, "Unable to initialize Vorbis encoder!\n");
+		vorbis_info_clear(&tmp->vi);
 		return -1;
 	}
 
@@ -273,6 +274,13 @@
 		 * and write out the rest of the data */
 		vorbis_analysis_wrote(&s->vd, 0);
 		write_stream(s, fs->f);
+
+		/* Cleanup */
+		ogg_stream_clear(&s->os);
+		vorbis_block_clear(&s->vb);
+		vorbis_dsp_clear(&s->vd);
+		vorbis_comment_clear(&s->vc);
+		vorbis_info_clear(&s->vi);
 	} else {
 		/* clear OggVorbis_File handle */
 		ov_clear(&s->ov_f);

-- 
To view, visit https://gerrit.asterisk.org/5477
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Iee94c5a5d5bdafbf8b181c5c064d15d90ace8274
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>



More information about the asterisk-code-review mailing list