]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/vf_drawtext: do not overread text if the last UTF8 sequence is invalid
authorMarton Balint <cus@passwd.hu>
Wed, 29 Jan 2020 22:55:25 +0000 (23:55 +0100)
committerMarton Balint <cus@passwd.hu>
Thu, 30 Jan 2020 23:15:13 +0000 (00:15 +0100)
Signed-off-by: Marton Balint <cus@passwd.hu>
libavfilter/vf_drawtext.c

index ed10175af08c8dcb2ec8be75570bda47e392b553..b58556e0f1e6d39f29d052f93968f1b474f69331 100644 (file)
@@ -1225,7 +1225,7 @@ static int draw_glyphs(DrawTextContext *s, AVFrame *frame,
     for (i = 0, p = text; *p; i++) {
         FT_Bitmap bitmap;
         Glyph dummy = { 0 };
-        GET_UTF8(code, *p++, code = 0xfffd; goto continue_on_invalid;);
+        GET_UTF8(code, *p ? *p++ : 0, code = 0xfffd; goto continue_on_invalid;);
 continue_on_invalid:
 
         /* skip new line chars, just go to new line */
@@ -1364,7 +1364,7 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame,
 
     /* load and cache glyphs */
     for (i = 0, p = text; *p; i++) {
-        GET_UTF8(code, *p++, code = 0xfffd; goto continue_on_invalid;);
+        GET_UTF8(code, *p ? *p++ : 0, code = 0xfffd; goto continue_on_invalid;);
 continue_on_invalid:
 
         /* get glyph */
@@ -1388,7 +1388,7 @@ continue_on_invalid:
     /* compute and save position for each glyph */
     glyph = NULL;
     for (i = 0, p = text; *p; i++) {
-        GET_UTF8(code, *p++, code = 0xfffd; goto continue_on_invalid2;);
+        GET_UTF8(code, *p ? *p++ : 0, code = 0xfffd; goto continue_on_invalid2;);
 continue_on_invalid2:
 
         /* skip the \n in the sequence \r\n */