X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;ds=sidebyside;f=libavformat%2Fcafdec.c;h=d0f942f3e46604417c651ac81f621fa7e1e415a2;hb=0a30683a01e4dacd48074bf19b95d4eb146b3564;hp=86228595c98459f44e3b3d007fe105217e4fb152;hpb=47e12966b75490cfa5fb8ed65a48a9a3d84a7bce;p=ffmpeg diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 86228595c98..d0f942f3e46 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -100,6 +100,7 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size) { AVIOContext *pb = s->pb; AVStream *st = s->streams[0]; + int ret; if (size < 0 || size > INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) return -1; @@ -134,9 +135,8 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size) return AVERROR_INVALIDDATA; } - av_freep(&st->codecpar->extradata); - if (ff_alloc_extradata(st->codecpar, ALAC_HEADER)) - return AVERROR(ENOMEM); + if ((ret = ff_alloc_extradata(st->codecpar, ALAC_HEADER)) < 0) + return ret; /* For the old style cookie, we skip 12 bytes, then read 36 bytes. * The new style cookie only contains the last 24 bytes of what was @@ -174,10 +174,8 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size) return AVERROR_PATCHWELCOME; } avio_skip(pb, size); - } else { - av_freep(&st->codecpar->extradata); - if (ff_get_extradata(s, st->codecpar, pb, size) < 0) - return AVERROR(ENOMEM); + } else if ((ret = ff_get_extradata(s, st->codecpar, pb, size)) < 0) { + return ret; } return 0;