[FFmpeg-devel] [PATCH] matroskadec: use av_grow_packet in merge_packets.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Mon Apr 16 21:53:23 CEST 2012


On 16 Apr 2012, at 18:13, Nicolas George <nicolas.george at normalesup.org> wrote:
> It ensures that the packet is properly padded
> and makes the code simpler.
> 
> Fixes trac ticket #1223.
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
> libavformat/matroskadec.c |   10 ++++------
> 1 files changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index e9c3101..2b97e72 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -1126,12 +1126,10 @@ static void matroska_fix_ass_packet(MatroskaDemuxContext *matroska,
> 
> static int matroska_merge_packets(AVPacket *out, AVPacket *in)
> {
> -    void *newdata = av_realloc(out->data, out->size+in->size);
> -    if (!newdata)
> -        return AVERROR(ENOMEM);
> -    out->data = newdata;
> -    memcpy(out->data+out->size, in->data, in->size);
> -    out->size += in->size;
> +    int ret = av_grow_packet(out, in->size);
> +    if (ret)
> +        return ret;

I think that should be "ret < 0". And I don't know if that might not leak memory on error (not sure what exactly that function does on error).


More information about the ffmpeg-devel mailing list