diff --git a/libavformat/mov.c b/libavformat/mov.c
index af94394516c5de76932e9da9c9bd775e2d9fc8f4..19e39339c89d35e8966fa39377f8333112e7740f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1831,6 +1831,9 @@ static int mov_read_elst(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
     get_be24(pb); /* flags */
     edit_count = get_be32(pb); /* entries */
 
+    if((uint64_t)edit_count*12+8 > atom.size)
+        return -1;
+
     for(i=0; i<edit_count; i++){
         int time;
         int duration = get_be32(pb); /* Track duration */