From 2ed47ab72509bbee60288d245a0aebb7eb05e41a Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Fri, 22 Aug 2025 16:50:34 +0200 Subject: [PATCH] avformat/rtsp: do not log invalid values When reading fails the first time, ch would be uninitialized and printed in the log message. Instead check for an error early and log it properly. --- libavformat/rtsp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 10355b89b8..13507d1858 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -1239,9 +1239,12 @@ start: q = buf; for (;;) { ret = ffurl_read_complete(rt->rtsp_hd, &ch, 1); + if (ret != 1) { + ret = (ret < 0) ? ret : AVERROR(EIO); + av_log(s, AV_LOG_WARNING, "Failed reading RTSP data: %s\n", av_err2str(ret)); + return ret; + } av_log(s, AV_LOG_TRACE, "ret=%d c=%02x [%c]\n", ret, ch, ch); - if (ret != 1) - return ret < 0 ? ret : AVERROR(EIO); if (ch == '\n') break; if (ch == '$' && q == buf) {