diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 58480dc36ac85b0c90588425d846b68f6d74aab2..4fc0e3dbb02228e3d8ed5a20879f921f8d190d75 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -178,6 +178,9 @@ static int asf_read_unknown(AVFormatContext *s, const GUIDParseTable *g)
     uint64_t size   = avio_rl64(pb);
     int ret;
 
+    if (size > INT64_MAX)
+        return AVERROR_INVALIDDATA;
+
     if (asf->is_header)
         asf->unknown_size = size;
     asf->is_header = 0;