diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index 03b7bd82ff89f830832862b23ac3ae3e113d3ccd..9951d756eac2c3cbda7e3f5ab7e667b59ec29609 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -359,6 +359,9 @@ static int ffm_read_packet(AVFormatContext *s, AVPacket *pkt)
     FFMContext *ffm = s->priv_data;
     int duration;
 
+    if (url_fsize(s->pb) == FFM_PACKET_SIZE)
+        return -1;
+
     switch(ffm->read_state) {
     case READ_HEADER:
         if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE+4)) {