[FFmpeg-cvslog] avcodec/movtextdec: Avoid loop when writing UTF-8 character to AVBPrint

Andreas Rheinhardt git at videolan.org
Mon Oct 19 06:37:27 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sat Oct 17 19:26:35 2020 +0200| [ba795890ec2de3150023433044cb4c9c5d1e7c74] | committer: Andreas Rheinhardt

avcodec/movtextdec: Avoid loop when writing UTF-8 character to AVBPrint

Reviewed-by: Philip Langdale <philipl at overt.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavcodec/movtextdec.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
index 1bfca8b79d..e5ce58a184 100644
--- a/libavcodec/movtextdec.c
+++ b/libavcodec/movtextdec.c
@@ -430,7 +430,6 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end,
             av_log(avctx, AV_LOG_ERROR, "invalid UTF-8 byte in subtitle\n");
             len = 1;
         }
-        for (i = 0; i < len; i++) {
             switch (*text) {
             case '\r':
                 break;
@@ -438,11 +437,10 @@ static int text_to_ass(AVBPrint *buf, const char *text, const char *text_end,
                 av_bprintf(buf, "\\N");
                 break;
             default:
-                av_bprint_chars(buf, *text, 1);
+                av_bprint_append_data(buf, text, len);
                 break;
             }
-            text++;
-        }
+        text += len;
         text_pos++;
     }
 



More information about the ffmpeg-cvslog mailing list