[FFmpeg-devel] [PATCH 1/3] lavc/srtenc: fix invalid read in case of SubRip.

Clément Bœsch ubitux at gmail.com
Fri Oct 26 23:19:02 CEST 2012


On Fri, Oct 26, 2012 at 10:18:30AM -0700, Philip Langdale wrote:
> On 2012-10-25 10:03, Clément Bœsch wrote:
> >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.
> >---
> > 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);
> >         }
> 
> Looks good to me.
> 

Thanks, applied.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20121026/9e374c21/attachment.asc>


More information about the ffmpeg-devel mailing list