diff --git a/libavformat/wc3movie.c b/libavformat/wc3movie.c
index 6d7592f0701d08bd1feebadd125e7d56b05fd806..59b11ae2b232b165e24702ffd0eafd550e1f60f3 100644
--- a/libavformat/wc3movie.c
+++ b/libavformat/wc3movie.c
@@ -293,7 +293,7 @@ static int wc3_read_packet(AVFormatContext *s,
         /* get the next chunk preamble */
         if ((ret = get_buffer(pb, preamble, WC3_PREAMBLE_SIZE)) !=
             WC3_PREAMBLE_SIZE)
-            ret = AVERROR(EIO);
+            return AVERROR(EIO);
 
         fourcc_tag = AV_RL32(&preamble[0]);
         /* chunk sizes are 16-bit aligned */