diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 1ba1bb20d0..d63640345b 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1238,6 +1238,7 @@ static int decode_frame_common(AVCodecContext *avctx, PNGDecContext *s,
                 }
                 av_log(avctx, AV_LOG_ERROR, ", skipping\n");
                 bytestream2_skip(&s->gb, length + 8); /* tag */
+                continue;
             }
         }
         tag = bytestream2_get_le32(&s->gb);