X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fcafdec.c;h=d0f942f3e46604417c651ac81f621fa7e1e415a2;hb=b2318c1e537f15c4c23f302a5193d6218dffdde8;hp=20956bcf977b949d405184772cc1ad4c16d5e76c;hpb=4dc1f06f0c84ebbd8b26cd77679450903244a3e8;p=ffmpeg diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 20956bcf977..d0f942f3e46 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -48,7 +48,7 @@ typedef struct CafContext { int64_t data_size; ///< raw data size, in bytes } CafContext; -static int probe(AVProbeData *p) +static int probe(const AVProbeData *p) { if (AV_RB32(p->buf) == MKBETAG('c','a','f','f') && AV_RB16(&p->buf[4]) == 1) return AVPROBE_SCORE_MAX; @@ -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;