[FFmpeg-cvslog] fftools/textformat/avtextformat: Initialize stuff earlier
Andreas Rheinhardt
git at videolan.org
Wed Apr 16 07:25:26 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Tue Apr 15 02:15:20 2025 +0200| [f873734f84a81ddd04ad41571f939dcd7048d014] | committer: Andreas Rheinhardt
fftools/textformat/avtextformat: Initialize stuff earlier
avtext_context_close() calls av_opt_free() on an AVTextFormatContext
as well as av_bprint_finalize() on the containing section_pbuf
AvBPrints, yet it can happen that the AVBPrints have not been
initialized (only zeroed) and that av_opt_set_defaults() has
not been called. This works, but it is not really documented to do so.
So ensure that the options and the AVBPrints have been initialized
when avtext_context_close() is called.
Reviewed-by: softworkz . <softworkz-at-hotmail.com at ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f873734f84a81ddd04ad41571f939dcd7048d014
---
fftools/textformat/avtextformat.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/fftools/textformat/avtextformat.c b/fftools/textformat/avtextformat.c
index 5e225825ba..4a90d8664f 100644
--- a/fftools/textformat/avtextformat.c
+++ b/fftools/textformat/avtextformat.c
@@ -144,6 +144,12 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form
goto fail;
}
+ for (int i = 0; i < SECTION_MAX_NB_LEVELS; i++)
+ av_bprint_init(&tctx->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED);
+
+ tctx->class = &textcontext_class;
+ av_opt_set_defaults(tctx);
+
if (!(tctx->priv = av_mallocz(formatter->priv_size))) {
ret = AVERROR(ENOMEM);
goto fail;
@@ -161,15 +167,12 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form
goto fail;
}
- tctx->class = &textcontext_class;
tctx->formatter = formatter;
tctx->level = -1;
tctx->sections = sections;
tctx->nb_sections = nb_sections;
tctx->writer = writer_context;
- av_opt_set_defaults(tctx);
-
if (formatter->priv_class) {
void *priv_ctx = tctx->priv;
*(const AVClass **)priv_ctx = formatter->priv_class;
@@ -232,9 +235,6 @@ int avtext_context_open(AVTextFormatContext **ptctx, const AVTextFormatter *form
}
}
- for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
- av_bprint_init(&tctx->section_pbuf[i], 1, AV_BPRINT_SIZE_UNLIMITED);
-
if (tctx->formatter->init)
ret = tctx->formatter->init(tctx);
if (ret < 0)
More information about the ffmpeg-cvslog
mailing list