mxfdec: fix memleak on av_realloc failures
This commit is contained in:
		@@ -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)
 | 
					static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size, UID uid, int64_t klv_offset)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    MXFContext *mxf = arg;
 | 
					    MXFContext *mxf = arg;
 | 
				
			||||||
    MXFPartition *partition;
 | 
					    MXFPartition *partition, *tmp_part;
 | 
				
			||||||
    UID op;
 | 
					    UID op;
 | 
				
			||||||
    uint64_t footer_partition;
 | 
					    uint64_t footer_partition;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions))
 | 
					    if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions))
 | 
				
			||||||
        return AVERROR(ENOMEM);
 | 
					        return AVERROR(ENOMEM);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    mxf->partitions = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions));
 | 
					    tmp_part = av_realloc(mxf->partitions, (mxf->partitions_count + 1) * sizeof(*mxf->partitions));
 | 
				
			||||||
    if (!mxf->partitions)
 | 
					    if (!tmp_part)
 | 
				
			||||||
        return AVERROR(ENOMEM);
 | 
					        return AVERROR(ENOMEM);
 | 
				
			||||||
 | 
					    mxf->partitions = tmp_part;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (mxf->parsing_backward) {
 | 
					    if (mxf->parsing_backward) {
 | 
				
			||||||
        /* insert the new partition pack in the middle
 | 
					        /* 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)
 | 
					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))
 | 
					    if (mxf->metadata_sets_count+1 >= UINT_MAX / sizeof(*mxf->metadata_sets))
 | 
				
			||||||
        return AVERROR(ENOMEM);
 | 
					        return AVERROR(ENOMEM);
 | 
				
			||||||
    mxf->metadata_sets = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets));
 | 
					    tmp = av_realloc(mxf->metadata_sets, (mxf->metadata_sets_count + 1) * sizeof(*mxf->metadata_sets));
 | 
				
			||||||
    if (!mxf->metadata_sets)
 | 
					    if (!tmp)
 | 
				
			||||||
        return AVERROR(ENOMEM);
 | 
					        return AVERROR(ENOMEM);
 | 
				
			||||||
 | 
					    mxf->metadata_sets = tmp;
 | 
				
			||||||
    mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set;
 | 
					    mxf->metadata_sets[mxf->metadata_sets_count] = metadata_set;
 | 
				
			||||||
    mxf->metadata_sets_count++;
 | 
					    mxf->metadata_sets_count++;
 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user