From patchwork Wed Jan 29 23:32:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 17621 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7E55F449B77 for ; Thu, 30 Jan 2020 01:32:57 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6BF9768B3CC; Thu, 30 Jan 2020 01:32:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 110E0688390 for ; Thu, 30 Jan 2020 01:32:50 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id EEFC5E3C43; Thu, 30 Jan 2020 00:32:49 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MxGeIkQGVViX; Thu, 30 Jan 2020 00:32:48 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 7A9C9E3B05; Thu, 30 Jan 2020 00:32:48 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Thu, 30 Jan 2020 00:32:34 +0100 Message-Id: <20200129233235.3325-5-cus@passwd.hu> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200129233235.3325-1-cus@passwd.hu> References: <20200129233235.3325-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 5/6] avfilter/vf_drawtext: use replacement chars for invalid UTF8 sequences X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" continue is explicitly disallowed for GET_UTF8, so let's fix that as well. Fixes crash with invalid UTF8 sequences. Signed-off-by: Marton Balint --- libavfilter/vf_drawtext.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index aea17b6793..ed10175af0 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1225,7 +1225,8 @@ 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++, continue;); + GET_UTF8(code, *p++, code = 0xfffd; goto continue_on_invalid;); +continue_on_invalid: /* skip new line chars, just go to new line */ if (code == '\n' || code == '\r' || code == '\t') @@ -1363,7 +1364,8 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame, /* load and cache glyphs */ for (i = 0, p = text; *p; i++) { - GET_UTF8(code, *p++, continue;); + GET_UTF8(code, *p++, code = 0xfffd; goto continue_on_invalid;); +continue_on_invalid: /* get glyph */ dummy.code = code; @@ -1386,7 +1388,8 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame, /* compute and save position for each glyph */ glyph = NULL; for (i = 0, p = text; *p; i++) { - GET_UTF8(code, *p++, continue;); + GET_UTF8(code, *p++, code = 0xfffd; goto continue_on_invalid2;); +continue_on_invalid2: /* skip the \n in the sequence \r\n */ if (prev_code == '\r' && code == '\n')