diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index dd6f9b6c954459a182b341802a5adc77c949b09d..268326d9a8572edc8bf7d78e186f099643d8a6b0 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -104,10 +104,8 @@ void put_byte(ByteIOContext *s, int b)
 
 void put_buffer(ByteIOContext *s, const unsigned char *buf, int size)
 {
-    int len;
-
     while (size > 0) {
-        len = FFMIN(s->buf_end - s->buf_ptr, size);
+        int len = FFMIN(s->buf_end - s->buf_ptr, size);
         memcpy(s->buf_ptr, buf, len);
         s->buf_ptr += len;