From: Hendrik Leppkes Date: Mon, 14 Nov 2016 11:41:32 +0000 (+0100) Subject: Merge commit '029cf99c5166b36f33381cd8ebfa5f1f1f463d1f' X-Git-Tag: android-x86-7.1-r1~3099 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=d8ffdefbdce16948c9b3c84df62171a7d58c8253;p=android-x86%2Fexternal-ffmpeg.git Merge commit '029cf99c5166b36f33381cd8ebfa5f1f1f463d1f' * commit '029cf99c5166b36f33381cd8ebfa5f1f1f463d1f': mov: Save number of stsd elements after stream extradata allocation Mostly noop, see 8b43ee4054af799e388d380b379a13a60849c1b5 Merged-by: Hendrik Leppkes --- d8ffdefbdce16948c9b3c84df62171a7d58c8253 diff --cc libavformat/mov.c index 17d63d66d0,0cb3271d44..8d6cc12bac --- a/libavformat/mov.c +++ b/libavformat/mov.c @@@ -2342,26 -1892,19 +2341,26 @@@ static int mov_read_stsd(MOVContext *c avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ - entries = avio_rb32(pb); /* entries */ + entries = avio_rb32(pb); + if (entries <= 0) { + av_log(c->fc, AV_LOG_ERROR, "invalid STSD entries %d\n", entries); + return AVERROR_INVALIDDATA; + } + + if (sc->extradata) { + av_log(c->fc, AV_LOG_ERROR, "Duplicate STSD\n"); + return AVERROR_INVALIDDATA; + } /* Prepare space for hosting multiple extradata. */ sc->extradata = av_mallocz_array(entries, sizeof(*sc->extradata)); - if (!sc->extradata) - return AVERROR(ENOMEM); - - sc->stsd_count = entries; - sc->extradata_size = av_mallocz_array(sc->stsd_count, sizeof(sc->extradata_size)); - if (!sc->extradata_size) - return AVERROR(ENOMEM); + sc->extradata_size = av_mallocz_array(entries, sizeof(*sc->extradata_size)); + if (!sc->extradata_size || !sc->extradata) { + ret = AVERROR(ENOMEM); + goto fail; + } - ret = ff_mov_read_stsd_entries(c, pb, sc->stsd_count); + ret = ff_mov_read_stsd_entries(c, pb, entries); if (ret < 0) return ret;