[FFmpeg-devel] Fwd: Leaking memory when decoding H264 streams + proposed patch fix to the problem

Luca Barbato lu_zero
Mon Apr 26 14:22:08 CEST 2010


On 04/22/2010 11:29 PM, Monica Morogan wrote:
> It helped me identify that one H264Context object was leaking. I have
> not included
> these wrappers in the patch below, but if you think that it might help
> you I will be glad
> to provide them.

Might be interesting please send them as a separate patch.

> diff -urp /media0/monicaff/ffmpeg-0.5.1/libavcodec/h264.c ./libavcodec/h264.c
> --- /media0/monicaff/ffmpeg-0.5.1/libavcodec/h264.c 2010-02-09
> 11:02:39.000000000 -0800
> +++ ./libavcodec/h264.c 2010-04-06 13:51:26.960044907 -0700
> @@ -1412,7 +1412,7 @@ const uint8_t *ff_h264_decode_nal(H264Co
> 
>     bufidx = h->nal_unit_type == NAL_DPC ? 1 : 0; // use second
> escape buffer for inter data
>     h->rbsp_buffer[bufidx]= av_fast_realloc(h->rbsp_buffer[bufidx],
> &h->rbsp_buffer_size[bufidx], length+FF_INPUT_BUFFER_PADDING_SIZE);
> -    dst= h->rbsp_buffer[bufidx];
> +    dst = h->rbsp_buffer[bufidx];

Cosmetics should go in a separate patch.

>     if (dst == NULL){
>         return NULL;
> @@ -1973,28 +1973,51 @@ static av_cold void decode_init_vlc(void
>     }
>  }
> 
> -static void free_tables(H264Context *h){
> -    int i;
> -    H264Context *hx;
> -    av_freep(&h->intra4x4_pred_mode);
> +void static free_tables(H264Context* h) {

Why that?

> +
> +   av_freep(&h->intra4x4_pred_mode);
> +    av_freep(&h->non_zero_count);

[snip]

You might try to clean it up a bit more and not mix cosmetic changes and
structural ones.

lu

-- 

Luca Barbato
Gentoo/linux
http://dev.gentoo.org/~lu_zero




More information about the ffmpeg-devel mailing list