1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

fftools/textformat/avtextformat: Fix segfault upon allocation error

Would happen if an AVTextFormatContext's private context
could not be allocated.

Reviewed-by: softworkz . <softworkz-at-hotmail.com@ffmpeg.org>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-04-15 02:11:57 +02:00
parent 7ee7632cb8
commit 50ef4b2a6b

View File

@ -112,12 +112,14 @@ int avtext_context_close(AVTextFormatContext **ptctx)
av_hash_freep(&tctx->hash); av_hash_freep(&tctx->hash);
if (tctx->formatter->uninit) if (tctx->formatter) {
tctx->formatter->uninit(tctx); if (tctx->formatter->uninit)
tctx->formatter->uninit(tctx);
if (tctx->formatter->priv_class)
av_opt_free(tctx->priv);
}
for (i = 0; i < SECTION_MAX_NB_LEVELS; i++) for (i = 0; i < SECTION_MAX_NB_LEVELS; i++)
av_bprint_finalize(&tctx->section_pbuf[i], NULL); av_bprint_finalize(&tctx->section_pbuf[i], NULL);
if (tctx->formatter->priv_class)
av_opt_free(tctx->priv);
av_freep(&tctx->priv); av_freep(&tctx->priv);
av_opt_free(tctx); av_opt_free(tctx);
av_freep(ptctx); av_freep(ptctx);