diff mbox series

[FFmpeg-devel,3/4] avformat/sccenc: avoid potential invalid access

Message ID 1652280498-10408-3-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit 8e828ee1add997ff3d1ca5539773a15df6b9f05e
Headers show
Series [FFmpeg-devel,1/4] remove sccenc dependency on subtitles | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Lance Wang May 11, 2022, 2:48 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/sccenc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/sccenc.c b/libavformat/sccenc.c
index c8c4d097e4..2b924ba6e7 100644
--- a/libavformat/sccenc.c
+++ b/libavformat/sccenc.c
@@ -72,11 +72,11 @@  static int scc_write_packet(AVFormatContext *avf, AVPacket *pkt)
     s = (int)(pts /  1000) % 60;
     f = (int)(pts %  1000) / 33;
 
-    for (i = 0; i < pkt->size; i+=3) {
+    for (i = 0; i < pkt->size - 2; i+=3) {
         if (pkt->data[i] == 0xfc && ((pkt->data[i + 1] != 0x80 || pkt->data[i + 2] != 0x80)))
             break;
     }
-    if (i >= pkt->size)
+    if (i >= pkt->size - 2)
         return 0;
 
     if (!scc->inside && (scc->prev_h != h || scc->prev_m != m || scc->prev_s != s || scc->prev_f != f)) {