diff options
author | Janne Grunau <janne-libav@jannau.net> | 2011-12-21 20:12:24 +0100 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2012-01-22 14:47:11 +0100 |
commit | 20ea14d0f812d337950cbbe9600d47b07352ba5d (patch) | |
tree | dc69452efe1783c2092ec57d26a2d733326d87d0 /libavformat/mxfdec.c | |
parent | fc85729458e994076cac661bd2dcecdd243b673f (diff) | |
download | ffmpeg-20ea14d0f812d337950cbbe9600d47b07352ba5d.tar.gz |
mxfdec: fix memleak on av_realloc failures
Diffstat (limited to 'libavformat/mxfdec.c')
-rw-r--r-- | libavformat/mxfdec.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index a81eec0519..4b63b277ff 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -407,16 +407,17 @@ 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; + MXFPartition *partition, *tmp_part; UID op; uint64_t footer_partition; if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions)) return AVERROR(ENOMEM); - mxf->partitions = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions)); - if (!mxf->partitions) + tmp_part = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions)); + if (!tmp_part) return AVERROR(ENOMEM); + mxf->partitions = tmp_part; if (mxf->parsing_backward) { /* insert the new partition pack in the middle @@ -512,11 +513,13 @@ 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; if (mxf->metadata_sets_count+1 >= UINT_MAX / sizeof(*mxf->metadata_sets)) return AVERROR(ENOMEM); - mxf->metadata_sets = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets)); - if (!mxf->metadata_sets) + tmp = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets)); + if (!tmp) return AVERROR(ENOMEM); + mxf->metadata_sets = tmp; mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set; mxf->metadata_sets_count++; return 0; |