]> git.sesse.net Git - ffmpeg/commitdiff
avformat/mov: Read the QT Metadata Keys only once
authorThierry Foucu <tfoucu@gmail.com>
Mon, 11 May 2020 16:35:00 +0000 (09:35 -0700)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 15 May 2020 20:03:36 +0000 (22:03 +0200)
If you have a file with multiple Metadata Keys, the second time you parse
the keys, you will re-alloc c->meta_keys without freeing the old one.
This change will avoid parsing all the consecutive Metadata keys.

Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/mov.c

index 93648994ebcbe063a2d54afb984d12806d736891..6490022b1d1ec3033dc0dd7c8286a63aa4814bf6 100644 (file)
@@ -7026,7 +7026,8 @@ static int mov_read_default(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         // https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/Metadata/Metadata.html
         if (!parse && c->found_hdlr_mdta &&
             atom.type == MKTAG('m','e','t','a') &&
-            a.type == MKTAG('k','e','y','s')) {
+            a.type == MKTAG('k','e','y','s') &&
+            c->meta_keys_count == 0) {
             parse = mov_read_keys;
         }