]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mxfdec: Fix leak on error
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 12 Mar 2021 12:16:38 +0000 (13:16 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 18 Mar 2021 23:42:27 +0000 (00:42 +0100)
It was introduced in d3d9b1fc8e2dfc8b4d66c9916ab7221062ff4660;
Fixes Coverity issue #733800.

Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavformat/mxfdec.c

index 8fea35b86b047adff30131f4e942d5cfd7d756dc..1f372affcb8d09feae215d7cf86a4fbe9f39367a 100644 (file)
@@ -2909,8 +2909,12 @@ static int mxf_read_local_tags(MXFContext *mxf, KLVPacket *klv, MXFMetadataReadF
         int size = avio_rb16(pb); /* KLV specified by 0x53 */
         int64_t next = avio_tell(pb);
         UID uid = {0};
-        if (next < 0 || next > INT64_MAX - size)
+        if (next < 0 || next > INT64_MAX - size) {
+            if (meta) {
+                mxf_free_metadataset(&meta, 1);
+            }
             return next < 0 ? next : AVERROR_INVALIDDATA;
+        }
         next += size;
 
         av_log(mxf->fc, AV_LOG_TRACE, "local tag %#04x size %d\n", tag, size);