[FFmpeg-devel] [PATCH] avcodec/truemotion2: Avoid duplicating array, fix memleak

Paul B Mahol onemda at gmail.com
Sat Aug 29 17:45:18 EEST 2020


On 8/29/20, Andreas Rheinhardt <andreas.rheinhardt at gmail.com> wrote:
> TrueMotion 2.0 uses Huffmann trees. To parse them, the decoder allocates
> arrays for the codes, their lengths and their value; afterwards a VLC
> table is initialized using these values. If everything up to this point
> succeeds, a new buffer of the same size as the already allocated arrays
> for the values is allocated and upon success the values are copied into
> the new array; all the old arrays are then freed. Yet if allocating the
> new array fails, the old arrays get freed, but the VLC table doesn't.
>
> This leak is fixed by not allocating a new array at all; instead the old
> array is simply reused, ensuring that nothing can fail after the
> creation of the VLC table.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libavcodec/truemotion2.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
>

probably ok


More information about the ffmpeg-devel mailing list