summaryrefslogtreecommitdiff
path: root/libavcodec/libtheoraenc.c
diff options
context:
space:
mode:
authorArt Clarke <aclarke@vlideshow.com>2009-07-13 01:59:45 +0000
committerDavid Conrad <lessen42@gmail.com>2009-07-13 01:59:45 +0000
commit870ee6f71579f2f3f20dee93d6246d12871c280d (patch)
tree6260f61fd9905009c05d7112048d1ba8a8297023 /libavcodec/libtheoraenc.c
parent38a9c529e27cfe054dc0ec1974b7fc4325130f98 (diff)
Fix memory leak in libtheora encoder
Patch by Art Clarke [aclark , xuggle . com] Originally committed as revision 19423 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/libtheoraenc.c')
-rw-r--r--libavcodec/libtheoraenc.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index f17834e994..04b8812882 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -150,6 +150,11 @@ static av_cold int encode_init(AVCodecContext* avc_context)
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(AVCodecContext* avc_context)
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(AVCodecContext* avc_context)
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 */