[FFmpeg-cvslog] avformat/mxfdec: functions that add entries should not destroy the whole list on failure

Michael Niedermayer git at videolan.org
Wed Sep 11 12:31:36 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed Sep 11 12:13:44 2013 +0200| [5ca39a0b899ae4542de8ed77b7a7f139e74d66ab] | committer: Michael Niedermayer

avformat/mxfdec: functions that add entries should not destroy the whole list on failure

The caller does not expect this and there are variables left that index to otherwise
deallocated data.

This reverts a hunk from "avformat: Use av_reallocp_array() where suitable"

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5ca39a0b899ae4542de8ed77b7a7f139e74d66ab
---

 libavformat/mxfdec.c |   24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 333f6b0..29a2f56 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -428,20 +428,18 @@ 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;
     uint32_t nb_essence_containers;
-    int err;
 
     if (mxf->partitions_count+1 >= UINT_MAX / sizeof(*mxf->partitions))
         return AVERROR(ENOMEM);
 
-    if ((err = av_reallocp_array(&mxf->partitions, mxf->partitions_count + 1,
-                                 sizeof(*mxf->partitions))) < 0) {
-        mxf->partitions_count = 0;
-        return err;
-    }
+    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
@@ -564,15 +562,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)
 {
-    int err;
-
+    MXFMetadataSet **tmp;
     if (mxf->metadata_sets_count+1 >= UINT_MAX / sizeof(*mxf->metadata_sets))
         return AVERROR(ENOMEM);
-    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;
-    }
+    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;



More information about the ffmpeg-cvslog mailing list