diff options
author | Alexandra Khirnova <alexandra.khirnova@gmail.com> | 2013-09-10 11:57:35 +0200 |
---|---|---|
committer | Diego Biurrun <diego@biurrun.de> | 2013-09-10 12:38:32 +0200 |
commit | f369b9356c4606cd4d713d60f7db5de119d901fa (patch) | |
tree | 174e199dd9716a32fbee4fb235d3938721fb333f /libavformat/mxfdec.c | |
parent | bdf990425e2be6912a6d29f032ca558448c8635a (diff) | |
download | ffmpeg-f369b9356c4606cd4d713d60f7db5de119d901fa.tar.gz |
avformat: Use av_reallocp_array() where suitable
Signed-off-by: Diego Biurrun <diego@biurrun.de>
Diffstat (limited to 'libavformat/mxfdec.c')
-rw-r--r-- | libavformat/mxfdec.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index d2039f6c35..7c0f6573f5 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -410,18 +410,20 @@ static int mxf_read_primer_pack(void *arg, AVIOContext *pb, int tag, int size, U static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset) { MXFContext *mxf = arg; - MXFPartition *partition, *tmp_part; + MXFPartition *partition; UID op; uint64_t footer_partition; uint32_t nb_essence_containers; + int err; if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions)) return AVERROR(ENOMEM); - tmp_part = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions)); - if (!tmp_part) - return AVERROR(ENOMEM); - mxf->partitions = tmp_part; + if ((err = av_reallocp_array(&mxf->partitions, mxf->partitions_count + 1, + sizeof(*mxf->partitions))) < 0) { + mxf->partitions_count = 0; + return err; + } if (mxf->parsing_backward) { /* insert the new partition pack in the middle @@ -546,13 +548,15 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size static int mxf_add_metadata_set(MXFContext *mxf, void *metadata_set) { - MXFMetadataSet **tmp; + int err; + if (mxf->metadata_sets_count+1 >= UINT_MAX / sizeof(*mxf->metadata_sets)) return AVERROR(ENOMEM); - tmp = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets)); - if (!tmp) - return AVERROR(ENOMEM); - mxf->metadata_sets = tmp; + if ((err = av_reallocp_array(&mxf->metadata_sets, mxf->metadata_sets_count + 1, + sizeof(*mxf->metadata_sets))) < 0) { + mxf->metadata_sets_count = 0; + return err; + } mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set; mxf->metadata_sets_count++; return 0; |