diff --git a/libavformat/cache.c b/libavformat/cache.c
index a762aa9ca50d5bcca9c25b735dabd949cfc3b066..31f63e6b183db238f4fc4cdd5d9c33dfb40a8e09 100644
--- a/libavformat/cache.c
+++ b/libavformat/cache.c
@@ -156,7 +156,7 @@ static int cache_read(URLContext *h, unsigned char *buf, int size)
 {
     Context *c= h->priv_data;
     CacheEntry *entry, *next[2] = {NULL, NULL};
-    int r;
+    int64_t r;
 
     entry = av_tree_find(c->root, &c->logical_pos, cmp, (void**)next);