[FFmpeg-devel] [PATCH] avformat/mov: fix memleak
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Sun Jun 28 00:09:09 EEST 2020
Zhao Zhili:
> Remove the check on dv_demux since dv_fctx will leak if allocate
> dv_demux failed.
> ---
> libavformat/mov.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index adc52de947..f179b6efdd 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -7357,10 +7357,9 @@ static int mov_read_close(AVFormatContext *s)
> av_freep(&sc->coll);
> }
>
> - if (mov->dv_demux) {
> - avformat_free_context(mov->dv_fctx);
> - mov->dv_fctx = NULL;
> - }
> + av_freep(&mov->dv_demux);
> + avformat_free_context(mov->dv_fctx);
> + mov->dv_fctx = NULL;
>
> if (mov->meta_keys) {
> for (i = 1; i < mov->meta_keys_count; i++) {
>
Do you have a sample for this? I am asking because there are more
memleaks related to dv audio and I have a patch [1] for them, but I
never found any sample for dv in mov/mp4, so it was never applied.
If I am not mistaken, then you are not only fixing a leak of dv_fctx in
case allocation of dv_demux failed; you are also fixing a leak of
dv_demux itself in the ordinary case where it could be successfully
allocated. This should be reflected in the commit message.
- Andreas
[1]:
https://patchwork.ffmpeg.org/project/ffmpeg/patch/20190916155502.17579-3-andreas.rheinhardt@gmail.com/
More information about the ffmpeg-devel
mailing list