diff mbox series

[FFmpeg-devel,1/5] fftools/ffprobe: Fix memleak

Message ID GV1P250MB0737C3EDF15EA842378D8DC58F05A@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 0e9956a06e9307e01232bc354665fadf6f7a09df
Headers show
Series [FFmpeg-devel,1/5] fftools/ffprobe: Fix memleak | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt July 31, 2023, 11:08 a.m. UTC
Fixes Coverity issue #1524491.
Regression since e6126abc6997058ca49ee596b70611bbe367163e.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 fftools/ffprobe.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

James Almer July 31, 2023, 12:57 p.m. UTC | #1
On 7/31/2023 8:08 AM, Andreas Rheinhardt wrote:
> Fixes Coverity issue #1524491.
> Regression since e6126abc6997058ca49ee596b70611bbe367163e.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>   fftools/ffprobe.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index 81610c097b..5c2d4cbff1 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -2929,8 +2929,10 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile,
>                   FrameData *fd;
>   
>                   pkt->opaque_ref = av_buffer_allocz(sizeof(*fd));
> -                if (!pkt->opaque_ref)
> -                    return AVERROR(ENOMEM);
> +                if (!pkt->opaque_ref) {
> +                    ret = AVERROR(ENOMEM);
> +                    goto end;
> +                }
>                   fd = (FrameData*)pkt->opaque_ref->data;
>                   fd->pkt_pos  = pkt->pos;
>                   fd->pkt_size = pkt->size;

LGTM.
Stefano Sabatini Aug. 2, 2023, 5:13 a.m. UTC | #2
On date Monday 2023-07-31 13:08:37 +0200, Andreas Rheinhardt wrote:
> Fixes Coverity issue #1524491.
> Regression since e6126abc6997058ca49ee596b70611bbe367163e.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  fftools/ffprobe.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
> index 81610c097b..5c2d4cbff1 100644
> --- a/fftools/ffprobe.c
> +++ b/fftools/ffprobe.c
> @@ -2929,8 +2929,10 @@ static int read_interval_packets(WriterContext *w, InputFile *ifile,
>                  FrameData *fd;
>  
>                  pkt->opaque_ref = av_buffer_allocz(sizeof(*fd));
> -                if (!pkt->opaque_ref)
> -                    return AVERROR(ENOMEM);
> +                if (!pkt->opaque_ref) {
> +                    ret = AVERROR(ENOMEM);
> +                    goto end;
> +                }
>                  fd = (FrameData*)pkt->opaque_ref->data;
>                  fd->pkt_pos  = pkt->pos;
>                  fd->pkt_size = pkt->size;

LGTM, thanks.
diff mbox series

Patch

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index 81610c097b..5c2d4cbff1 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -2929,8 +2929,10 @@  static int read_interval_packets(WriterContext *w, InputFile *ifile,
                 FrameData *fd;
 
                 pkt->opaque_ref = av_buffer_allocz(sizeof(*fd));
-                if (!pkt->opaque_ref)
-                    return AVERROR(ENOMEM);
+                if (!pkt->opaque_ref) {
+                    ret = AVERROR(ENOMEM);
+                    goto end;
+                }
                 fd = (FrameData*)pkt->opaque_ref->data;
                 fd->pkt_pos  = pkt->pos;
                 fd->pkt_size = pkt->size;