diff mbox

[FFmpeg-devel,V1,2/5] lavfi/avfiltergraph: add check before free the format

Message ID 1566219667-22805-2-git-send-email-mypopydev@gmail.com
State Accepted
Commit f156f4ab2317f22bfef33c7eaead0d5d5f162903
Headers show

Commit Message

Jun Zhao Aug. 19, 2019, 1:01 p.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

ff_merge_samplerates will be deallocate a or b in some case, so
add a check before free the format.

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavfilter/avfiltergraph.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Comments

Paul B Mahol Aug. 19, 2019, 1:09 p.m. UTC | #1
LGTM

On Mon, Aug 19, 2019 at 3:08 PM Jun Zhao <mypopydev@gmail.com> wrote:

> From: Jun Zhao <barryjzhao@tencent.com>
>
> ff_merge_samplerates will be deallocate a or b in some case, so
> add a check before free the format.
>
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
>  libavfilter/avfiltergraph.c |    6 ++++--
>  1 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
> index a149f8f..2fe4f0b 100644
> --- a/libavfilter/avfiltergraph.c
> +++ b/libavfilter/avfiltergraph.c
> @@ -419,8 +419,10 @@ static int can_merge_formats(AVFilterFormats *a_arg,
>          av_freep(&ret);
>          return 1;
>      } else {
> -        av_freep(&a->formats);
> -        av_freep(&b->formats);
> +        if (a)
> +            av_freep(&a->formats);
> +        if (b)
> +            av_freep(&b->formats);
>          av_freep(&a);
>          av_freep(&b);
>          return 0;
> --
> 1.7.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Jun Zhao Aug. 20, 2019, 2:02 a.m. UTC | #2
On Mon, Aug 19, 2019 at 9:09 PM Paul B Mahol <onemda@gmail.com> wrote:
>
> LGTM
>

Will apply, Thanks
diff mbox

Patch

diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index a149f8f..2fe4f0b 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -419,8 +419,10 @@  static int can_merge_formats(AVFilterFormats *a_arg,
         av_freep(&ret);
         return 1;
     } else {
-        av_freep(&a->formats);
-        av_freep(&b->formats);
+        if (a)
+            av_freep(&a->formats);
+        if (b)
+            av_freep(&b->formats);
         av_freep(&a);
         av_freep(&b);
         return 0;