[FFmpeg-cvslog] r19423 - trunk/libavcodec/libtheoraenc.c

conrad subversion
Mon Jul 13 03:59:45 CEST 2009


Author: conrad
Date: Mon Jul 13 03:59:45 2009
New Revision: 19423

Log:
Fix memory leak in libtheora encoder
Patch by Art Clarke [aclark , xuggle . com]

Modified:
   trunk/libavcodec/libtheoraenc.c

Modified: trunk/libavcodec/libtheoraenc.c
==============================================================================
--- trunk/libavcodec/libtheoraenc.c	Mon Jul 13 01:03:08 2009	(r19422)
+++ trunk/libavcodec/libtheoraenc.c	Mon Jul 13 03:59:45 2009	(r19423)
@@ -150,6 +150,11 @@ static av_cold int encode_init(AVCodecCo
     if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) {
         return -1;
     }
+    /* Clear up theora_comment struct before we reset the packet */
+    theora_comment_clear( &t_comment );
+    /* And despite documentation to the contrary, theora_comment_clear
+     * does not release the packet */
+    ogg_packet_clear(&o_packet);
 
     /* Tables */
     theora_encode_tables( &(h->t_state), &o_packet );
@@ -157,9 +162,6 @@ static av_cold int encode_init(AVCodecCo
         return -1;
     }
 
-    /* Clear up theora_comment struct */
-    theora_comment_clear( &t_comment );
-
     /* Set up the output AVFrame */
     avc_context->coded_frame= avcodec_alloc_frame();
 
@@ -249,6 +251,10 @@ static av_cold int encode_close(AVCodecC
 
     result = theora_encode_packetout( &(h->t_state), 1, &o_packet );
     theora_clear( &(h->t_state) );
+    av_freep(&avc_context->coded_frame);
+    av_freep(&avc_context->extradata);
+    avc_context->extradata_size = 0;
+
     switch (result) {
         case 0:/* No packet is ready */
         case -1:/* Encoding finished */



More information about the ffmpeg-cvslog mailing list