diff --git a/libavformat/nuv.c b/libavformat/nuv.c
index e707854ef303907af003da9aedf7bc6977ea01d7..5cb1a3c88ceacf0426564dfcf77e916a9bb80908 100644
--- a/libavformat/nuv.c
+++ b/libavformat/nuv.c
@@ -186,7 +186,7 @@ static int nuv_packet(AVFormatContext *s, AVPacket *pkt) {
     while (!url_feof(pb)) {
         ret = get_buffer(pb, hdr, HDRSIZE);
         if (ret <= 0)
-            return ret;
+            return ret ? ret : -1;
         frametype = hdr[0];
         size = PKTSIZE(LE_32(&hdr[8]));
         switch (frametype) {