[FFmpeg-cvslog] lavc/srtenc: fix invalid read in case of SubRip.

Clément Bœsch git at videolan.org
Fri Oct 26 23:18:16 CEST 2012


ffmpeg | branch: master | Clément Bœsch <ubitux at gmail.com> | Thu Oct 25 18:50:26 2012 +0200| [eb36ee1ee11c269e24ad4595fadf50e78463d5e2] | committer: Clément Bœsch

lavc/srtenc: fix invalid read in case of SubRip.

Regression since 6057de19b. The ptr-2 is used to eat the \r\n and add
the position information on the timing line. This can't be done in case
of SubRip where the timing isn't present in the payload.

Note that we can't use yet the side data to transmit the position
information since the encode subtitles API is still using buffer+size
instead AVPacket as input.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb36ee1ee11c269e24ad4595fadf50e78463d5e2
---

 libavcodec/srtenc.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libavcodec/srtenc.c b/libavcodec/srtenc.c
index 473c88f..56f29e9 100644
--- a/libavcodec/srtenc.c
+++ b/libavcodec/srtenc.c
@@ -203,6 +203,8 @@ static void srt_move_cb(void *priv, int x1, int y1, int x2, int y2,
                         int t1, int t2)
 {
     SRTContext *s = priv;
+
+    if (s->avctx->codec->id == CODEC_ID_SRT) {
     char buffer[32];
     int len = snprintf(buffer, sizeof(buffer),
                        "  X1:%03u X2:%03u Y1:%03u Y2:%03u", x1, x2, y1, y2);
@@ -211,6 +213,7 @@ static void srt_move_cb(void *priv, int x1, int y1, int x2, int y2,
         memcpy(s->dialog_start, buffer, len);
         s->ptr += len;
     }
+    }
 }
 
 static void srt_end_cb(void *priv)
@@ -262,9 +265,9 @@ static int srt_encode_frame(AVCodecContext *avctx,
                 es = ec/   1000;  ec -=    1000*es;
                 srt_print(s,"%d\r\n%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\r\n",
                           ++s->count, sh, sm, ss, sc, eh, em, es, ec);
+                s->dialog_start = s->ptr - 2;
             }
             s->alignment_applied = 0;
-            s->dialog_start = s->ptr - 2;
             srt_style_apply(s, dialog->style);
             ff_ass_split_override_codes(&srt_callbacks, s, dialog->text);
         }



More information about the ffmpeg-cvslog mailing list