From 6336fa33358cd860f74c8be4772bbc303311b71e Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Fri, 23 Jan 2026 11:16:16 +0100 Subject: [PATCH] avformat/http: return EIO if s->hd is NULL This could conceivably happen currently if the user tries reading more bytes after the last chunk has already been received. In this case, we currently segfault - but simply returning AVERROR(EIO) seems more reasonable and lets the higher end retry the connection in this case. --- libavformat/http.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/http.c b/libavformat/http.c index 0fbf84165a..16da46a0e1 100644 --- a/libavformat/http.c +++ b/libavformat/http.c @@ -1658,6 +1658,9 @@ static int http_buf_read(URLContext *h, uint8_t *buf, int size) HTTPContext *s = h->priv_data; int len; + if (!s->hd) + return AVERROR(EIO); + if (s->chunksize != UINT64_MAX) { if (s->chunkend) { return AVERROR_EOF;