diff --git a/libavformat/asfdec_o.c b/libavformat/asfdec_o.c
index f7889a40e1ab45db8f53c9ecdfca9bee5d53d937..016af0c1edb634f030afa1b7e3febe53e883dee9 100644
--- a/libavformat/asfdec_o.c
+++ b/libavformat/asfdec_o.c
@@ -1591,6 +1591,8 @@ static int detect_unknown_subobject(AVFormatContext *s, int64_t offset, int64_t
     int ret;
 
     while (avio_tell(pb) <= offset + size) {
+        if (avio_tell(pb) == asf->offset)
+            break;
         asf->offset = avio_tell(pb);
         if ((ret = ff_get_guid(pb, &guid)) < 0)
             return ret;