diff mbox series

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

Message ID AM7PR03MB6660195BB2496AC5498310178FAB9@AM7PR03MB6660.eurprd03.prod.outlook.com
State Accepted
Commit 8766361fc16b6d25ee8be880bf55c9761490cb99
Headers show
Series [FFmpeg-devel,01/20] libpostproc/postprocess_template: Don't reimplement FFSWAP | expand


Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 1, 2021, 9:08 p.m. UTC
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@outlook.com>
 libavformat/subtitles.c | 1 +
 1 file changed, 1 insertion(+)


Paul B Mahol Oct. 2, 2021, 3:05 p.m. UTC | #1
diff mbox series


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)