diff --git a/libavcodec/h264.c b/libavcodec/h264.c index cd088e17b0..d7ec5d959a 100644 --- a/libavcodec/h264.c +++ b/libavcodec/h264.c @@ -2726,6 +2726,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0) h->slice_type = slice_type; h->slice_type_nos = slice_type & 3; + if (h->nal_unit_type == NAL_IDR_SLICE && + h->slice_type_nos != AV_PICTURE_TYPE_I) { + av_log(h->s.avctx, AV_LOG_ERROR, "A non-intra slice in an IDR NAL unit.\n"); + return AVERROR_INVALIDDATA; + } + // to make a few old functions happy, it's wrong though s->pict_type = h->slice_type; diff --git a/libavformat/mov.c b/libavformat/mov.c index 1e6e1140a6..0f0c411373 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1808,6 +1808,7 @@ static int mov_read_stts(MOVContext *c, AVIOContext *pb, MOVAtom atom) if (entries >= UINT_MAX / sizeof(*sc->stts_data)) return -1; + av_free(sc->stts_data); sc->stts_data = av_malloc(entries * sizeof(*sc->stts_data)); if (!sc->stts_data) return AVERROR(ENOMEM);