avformat/ffmdec: Only return EAGAIN if a server is attached
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 20 Nov 2015 02:10:11 +0000 (03:10 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 20 Nov 2015 19:08:26 +0000 (20:08 +0100)
This should fix a infinite loop

Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/ffmdec.c

index c3850dbf4f4d1e24133e356a28c26087ac4771b9..e7c1449ea4befe75c76cfc5915ca0cc63855e499 100644 (file)
@@ -49,7 +49,10 @@ static int ffm_is_avail_data(AVFormatContext *s, int size)
     } else {
     if (pos == ffm->write_index) {
         /* exactly at the end of stream */
-        return AVERROR(EAGAIN);
+        if (ffm->server_attached)
+            return AVERROR(EAGAIN);
+        else
+            return AVERROR_INVALIDDATA;
     } else if (pos < ffm->write_index) {
         avail_size = ffm->write_index - pos;
     } else {
@@ -59,8 +62,10 @@ static int ffm_is_avail_data(AVFormatContext *s, int size)
     avail_size = (avail_size / ffm->packet_size) * (ffm->packet_size - FFM_HEADER_SIZE) + len;
     if (size <= avail_size)
         return 1;
-    else
+    else if (ffm->server_attached)
         return AVERROR(EAGAIN);
+    else
+        return AVERROR_INVALIDDATA;
 }
 
 static int ffm_resync(AVFormatContext *s, int state)