aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_drawtext.c
diff options
context:
space:
mode:
authorNicolas George <george@nsup.org>2020-11-30 19:28:36 +0100
committerNicolas George <george@nsup.org>2021-02-17 11:53:51 +0100
commit670051b52487cf71890909d1020a067169d743cc (patch)
treec9c0bfc005886066fd6763d00ceb32eb78c1f792 /libavfilter/vf_drawtext.c
parent8331eb058d884897aca2ef62ac9b98b536caec6e (diff)
downloadffmpeg-670051b52487cf71890909d1020a067169d743cc.tar.gz
lavfi/drawtext: ignore final LF of textfile.
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.
Diffstat (limited to 'libavfilter/vf_drawtext.c')
-rw-r--r--libavfilter/vf_drawtext.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
index abe1ca6c35..7b1000e5bd 100644
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -568,6 +568,11 @@ static int load_font(AVFilterContext *ctx)
return err;
}
+static inline int is_newline(uint32_t c)
+{
+ return c == '\n' || c == '\r' || c == '\f' || c == '\v';
+}
+
static int load_textfile(AVFilterContext *ctx)
{
DrawTextContext *s = ctx->priv;
@@ -583,6 +588,8 @@ static int load_textfile(AVFilterContext *ctx)
return err;
}
+ if (textbuf_size > 0 && is_newline(textbuf[textbuf_size - 1]))
+ 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);
@@ -595,11 +602,6 @@ static int load_textfile(AVFilterContext *ctx)
return 0;
}
-static inline int is_newline(uint32_t c)
-{
- return c == '\n' || c == '\r' || c == '\f' || c == '\v';
-}
-
#if CONFIG_LIBFRIBIDI
static int shape_text(AVFilterContext *ctx)
{