Merge "demux.c: remove redundant check" into main
diff --git a/src/demux/demux.c b/src/demux/demux.c
index 4b2f1a1..33795e5 100644
--- a/src/demux/demux.c
+++ b/src/demux/demux.c
@@ -311,7 +311,6 @@
 static ParseStatus ParseAnimationFrame(WebPDemuxer* const dmux,
                                        uint32_t frame_chunk_size) {
   const int is_animation = !!(dmux->feature_flags & ANIMATION_FLAG);
-  const uint32_t anmf_payload_size = frame_chunk_size - ANMF_CHUNK_SIZE;
   int added_frame = 0;
   int bits;
   MemBuffer* const mem = &dmux->mem;
@@ -337,9 +336,13 @@
   // Store a frame only if the animation flag is set there is some data for
   // this frame is available.
   start_offset = mem->start;
-  status = StoreFrame(dmux->num_frames + 1, anmf_payload_size, mem, frame);
-  if (status != PARSE_ERROR && mem->start - start_offset > anmf_payload_size) {
-    status = PARSE_ERROR;
+  {
+    const uint32_t anmf_payload_size = frame_chunk_size - ANMF_CHUNK_SIZE;
+    status = StoreFrame(dmux->num_frames + 1, anmf_payload_size, mem, frame);
+    if (status != PARSE_ERROR &&
+        mem->start - start_offset > anmf_payload_size) {
+      status = PARSE_ERROR;
+    }
   }
   if (status != PARSE_ERROR && is_animation && frame->frame_num > 0) {
     added_frame = AddFrame(dmux, frame);
@@ -493,7 +496,6 @@
       }
       case MKFOURCC('A', 'N', 'M', 'F'): {
         if (anim_chunks == 0) return PARSE_ERROR;  // 'ANIM' precedes frames.
-        if (chunk_size_padded < ANMF_CHUNK_SIZE) return PARSE_ERROR;
         status = ParseAnimationFrame(dmux, chunk_size_padded);
         break;
       }