diff --git a/libavformat/utils.c b/libavformat/utils.c
index 929f5a418c85c76127a561259473c2d58119525b..0cb5e4702e01b8ccd99eba5c31e835ae85659873 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -562,7 +562,7 @@ int av_open_input_file(AVFormatContext **ic_ptr, const char *filename,
         if (buf_size > 0) {
             url_setbufsize(pb, buf_size);
         }
-        if ((err = ff_probe_input_buffer(&pb, &fmt, filename, logctx, 0, 0)) < 0) {
+        if ((err = ff_probe_input_buffer(&pb, &fmt, filename, logctx, 0, logctx ? (*ic_ptr)->probesize : 0)) < 0) {
             goto fail;
         }
     }