Mercurial > libavcodec.hg
comparison libtheoraenc.c @ 9951:702e111de423 libavcodec
Fix memory leak in libtheora encoder
Patch by Art Clarke [aclark , xuggle . com]
author | conrad |
---|---|
date | Mon, 13 Jul 2009 01:59:45 +0000 |
parents | d9f8496b3b91 |
children | 4b3abcad0628 |
comparison
equal
deleted
inserted
replaced
9950:a23ecc9d7976 | 9951:702e111de423 |
---|---|
148 theora_comment_init( &t_comment ); | 148 theora_comment_init( &t_comment ); |
149 theora_encode_comment( &t_comment, &o_packet ); | 149 theora_encode_comment( &t_comment, &o_packet ); |
150 if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) { | 150 if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) { |
151 return -1; | 151 return -1; |
152 } | 152 } |
153 /* Clear up theora_comment struct before we reset the packet */ | |
154 theora_comment_clear( &t_comment ); | |
155 /* And despite documentation to the contrary, theora_comment_clear | |
156 * does not release the packet */ | |
157 ogg_packet_clear(&o_packet); | |
153 | 158 |
154 /* Tables */ | 159 /* Tables */ |
155 theora_encode_tables( &(h->t_state), &o_packet ); | 160 theora_encode_tables( &(h->t_state), &o_packet ); |
156 if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) { | 161 if (concatenate_packet( &offset, avc_context, &o_packet ) != 0) { |
157 return -1; | 162 return -1; |
158 } | 163 } |
159 | |
160 /* Clear up theora_comment struct */ | |
161 theora_comment_clear( &t_comment ); | |
162 | 164 |
163 /* Set up the output AVFrame */ | 165 /* Set up the output AVFrame */ |
164 avc_context->coded_frame= avcodec_alloc_frame(); | 166 avc_context->coded_frame= avcodec_alloc_frame(); |
165 | 167 |
166 return 0; | 168 return 0; |
247 int result; | 249 int result; |
248 const char* message; | 250 const char* message; |
249 | 251 |
250 result = theora_encode_packetout( &(h->t_state), 1, &o_packet ); | 252 result = theora_encode_packetout( &(h->t_state), 1, &o_packet ); |
251 theora_clear( &(h->t_state) ); | 253 theora_clear( &(h->t_state) ); |
254 av_freep(&avc_context->coded_frame); | |
255 av_freep(&avc_context->extradata); | |
256 avc_context->extradata_size = 0; | |
257 | |
252 switch (result) { | 258 switch (result) { |
253 case 0:/* No packet is ready */ | 259 case 0:/* No packet is ready */ |
254 case -1:/* Encoding finished */ | 260 case -1:/* Encoding finished */ |
255 return 0; | 261 return 0; |
256 case 1: | 262 case 1: |