[PATCH] ad_spdif: Use avformat_free_context to free context.
This avoids memleaks and in newest FFmpeg versions also compile errors. --- libmpcodecs/ad_spdif.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libmpcodecs/ad_spdif.c b/libmpcodecs/ad_spdif.c index 1fc237b6d..8ee472429 100644 --- a/libmpcodecs/ad_spdif.c +++ b/libmpcodecs/ad_spdif.c @@ -298,14 +298,8 @@ static void uninit(sh_audio_t *sh) if (spdif_ctx->header_written) av_write_trailer(lavf_ctx); av_freep(&lavf_ctx->pb); - if (lavf_ctx->streams) { - av_freep(&lavf_ctx->streams[0]->codec); - av_freep(&lavf_ctx->streams[0]->info); - av_freep(&lavf_ctx->streams[0]); - } - av_freep(&lavf_ctx->streams); - av_freep(&lavf_ctx->priv_data); + avformat_free_context(lavf_ctx); + lavf_ctx = NULL; } - av_freep(&lavf_ctx); av_freep(&spdif_ctx); } -- 2.29.1
On 2020-10-31 19:54 +0100, Reimar Döffinger wrote:
This avoids memleaks and in newest FFmpeg versions also compile errors. --- libmpcodecs/ad_spdif.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/libmpcodecs/ad_spdif.c b/libmpcodecs/ad_spdif.c index 1fc237b6d..8ee472429 100644 --- a/libmpcodecs/ad_spdif.c +++ b/libmpcodecs/ad_spdif.c @@ -298,14 +298,8 @@ static void uninit(sh_audio_t *sh) if (spdif_ctx->header_written) av_write_trailer(lavf_ctx); av_freep(&lavf_ctx->pb); - if (lavf_ctx->streams) { - av_freep(&lavf_ctx->streams[0]->codec); - av_freep(&lavf_ctx->streams[0]->info); - av_freep(&lavf_ctx->streams[0]); - } - av_freep(&lavf_ctx->streams); - av_freep(&lavf_ctx->priv_data); + avformat_free_context(lavf_ctx); + lavf_ctx = NULL; } - av_freep(&lavf_ctx); av_freep(&spdif_ctx); }
LGTM IMHO go ahead and push, so building against FFmpeg master works again. Greetings, Alexander
On Sat, Oct 31, 2020 at 08:50:58PM +0100, Alexander Strasser wrote:
On 2020-10-31 19:54 +0100, Reimar Döffinger wrote:
This avoids memleaks and in newest FFmpeg versions also compile errors.
LGTM
IMHO go ahead and push, so building against FFmpeg master works again.
Done
participants (2)
-
Alexander Strasser -
Reimar Döffinger