[FFmpeg-devel] [PATCH 11/20] avformat/subtitles: Honour ff_subtitles_read_line() documentation

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sat Oct 2 00:08:28 EEST 2021


It claims to always zero-terminate its buffer like snprintf(),
yet it does it not on EOF. Because of this the mcc demuxer
used uninitialized values when reading an empty input file.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavformat/subtitles.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/subtitles.c b/libavformat/subtitles.c
index c6701c6a60..3ba5e2b217 100644
--- a/libavformat/subtitles.c
+++ b/libavformat/subtitles.c
@@ -437,6 +437,7 @@ ptrdiff_t ff_subtitles_read_line(FFTextReader *tr, char *buf, size_t size)
     size_t cur = 0;
     if (!size)
         return 0;
+    buf[0] = '\0';
     while (cur + 1 < size) {
         unsigned char c = ff_text_r8(tr);
         if (!c)
-- 
2.30.2



More information about the ffmpeg-devel mailing list