From patchwork Mon Nov 30 18:38:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 24216 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 7E83B44A9F8 for ; Mon, 30 Nov 2020 20:38:19 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5DCAF680A72; Mon, 30 Nov 2020 20:38:19 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E866A680635 for ; Mon, 30 Nov 2020 20:38:12 +0200 (EET) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 0AUIcBQl018523 for ; Mon, 30 Nov 2020 19:38:12 +0100 Received: by phare.normalesup.org (Postfix, from userid 1001) id CAE8CE0095; Mon, 30 Nov 2020 19:38:11 +0100 (CET) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Mon, 30 Nov 2020 19:38:10 +0100 Message-Id: <20201130183810.507651-1-george@nsup.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Mon, 30 Nov 2020 19:38:12 +0100 (CET) Subject: [FFmpeg-devel] [PATCH] lavfi/drawtext: ignore final LF of textfile. 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" A standard text file ends with a final LF. Without this change, it is interpreted as an empty final line, and visible with the box option. The current behavior can be achieved by actually having an empty line at the end of the file. Fix trac ticket #7948. Signed-off-by: Nicolas George --- libavfilter/vf_drawtext.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index abe1ca6c35..0cc47e84a9 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -583,6 +583,8 @@ static int load_textfile(AVFilterContext *ctx) return err; } + if (textbuf_size > 0 && textbuf[textbuf_size - 1] == '\n') + textbuf_size--; if (textbuf_size > SIZE_MAX - 1 || !(tmp = av_realloc(s->text, textbuf_size + 1))) { av_file_unmap(textbuf, textbuf_size); return AVERROR(ENOMEM);