Message ID | 20201130183810.507651-1-george@nsup.org |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] lavfi/drawtext: ignore final LF of textfile. | expand |
Context | Check | Description |
---|---|---|
andriy/x86_make | success | Make finished |
andriy/x86_make_fate | success | Make fate finished |
On 01-12-2020 12:08 am, Nicolas George wrote: > 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 <george@nsup.org> > --- > 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') Isn't it better to use is_newline() Regards, Gyan
Gyan Doshi (12020-12-01):
> Isn't it better to use is_newline()
Good idea, thanks.
Regards,
Nicolas George (12020-11-30):
> Good idea, thanks.
Pushed.
Regards,
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);
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 <george@nsup.org> --- libavfilter/vf_drawtext.c | 2 ++ 1 file changed, 2 insertions(+)