diff mbox series

[FFmpeg-devel] avformat/utils: Fix NPD when allocating AVStreamInternal fails

Message ID HE1PR0301MB2154D49CDBE542A9F22718F48F519@HE1PR0301MB2154.eurprd03.prod.outlook.com
State Accepted
Headers show
Series [FFmpeg-devel] avformat/utils: Fix NPD when allocating AVStreamInternal fails | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt May 13, 2021, 8:22 p.m. UTC
Regression since b9c5fdf6027010d15ee90a43aa023e45a5189097;
fixes Coverity ID #1484786.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
Checking for st->internal->parser is btw unnecessary as
av_parser_close(NULL) is safe.

 libavformat/utils.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

James Almer May 13, 2021, 8:40 p.m. UTC | #1
On 5/13/2021 5:22 PM, Andreas Rheinhardt wrote:
> Regression since b9c5fdf6027010d15ee90a43aa023e45a5189097;
> fixes Coverity ID #1484786.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> Checking for st->internal->parser is btw unnecessary as
> av_parser_close(NULL) is safe.
> 
>   libavformat/utils.c | 5 ++---
>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 492e08562e..85546267f5 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4262,13 +4262,12 @@ static void free_stream(AVStream **pst)
>           av_freep(&st->side_data[i].data);
>       av_freep(&st->side_data);
>   
> -    if (st->internal->parser)
> -        av_parser_close(st->internal->parser);
> -
>       if (st->attached_pic.data)
>           av_packet_unref(&st->attached_pic);
>   
>       if (st->internal) {
> +        if (st->internal->parser)
> +            av_parser_close(st->internal->parser);
>           avcodec_free_context(&st->internal->avctx);
>           av_bsf_free(&st->internal->bsfc);
>           av_freep(&st->internal->priv_pts);

LGTM.
Marton Balint May 13, 2021, 8:43 p.m. UTC | #2
On Thu, 13 May 2021, Andreas Rheinhardt wrote:

> Regression since b9c5fdf6027010d15ee90a43aa023e45a5189097;
> fixes Coverity ID #1484786.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> Checking for st->internal->parser is btw unnecessary as
> av_parser_close(NULL) is safe.

I think it is fine if you also remove the if() in this patch then.

Thanks,
Marton

>
> libavformat/utils.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 492e08562e..85546267f5 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -4262,13 +4262,12 @@ static void free_stream(AVStream **pst)
>         av_freep(&st->side_data[i].data);
>     av_freep(&st->side_data);
>
> -    if (st->internal->parser)
> -        av_parser_close(st->internal->parser);
> -
>     if (st->attached_pic.data)
>         av_packet_unref(&st->attached_pic);
>
>     if (st->internal) {
> +        if (st->internal->parser)
> +            av_parser_close(st->internal->parser);
>         avcodec_free_context(&st->internal->avctx);
>         av_bsf_free(&st->internal->bsfc);
>         av_freep(&st->internal->priv_pts);
> -- 
> 2.27.0
>
> _______________________________________________
> 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".
>
Andreas Rheinhardt May 13, 2021, 9:09 p.m. UTC | #3
Marton Balint:
> 
> 
> On Thu, 13 May 2021, Andreas Rheinhardt wrote:
> 
>> Regression since b9c5fdf6027010d15ee90a43aa023e45a5189097;
>> fixes Coverity ID #1484786.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>> Checking for st->internal->parser is btw unnecessary as
>> av_parser_close(NULL) is safe.
> 
> I think it is fine if you also remove the if() in this patch then.
> 

Applied with that change. Thanks for review.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/utils.c b/libavformat/utils.c
index 492e08562e..85546267f5 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4262,13 +4262,12 @@  static void free_stream(AVStream **pst)
         av_freep(&st->side_data[i].data);
     av_freep(&st->side_data);
 
-    if (st->internal->parser)
-        av_parser_close(st->internal->parser);
-
     if (st->attached_pic.data)
         av_packet_unref(&st->attached_pic);
 
     if (st->internal) {
+        if (st->internal->parser)
+            av_parser_close(st->internal->parser);
         avcodec_free_context(&st->internal->avctx);
         av_bsf_free(&st->internal->bsfc);
         av_freep(&st->internal->priv_pts);