diff mbox series

[FFmpeg-devel] avdevice/gdigrab: Memory leak if BitBlt return false.

Message ID 20201022132300.1626-1-dont.buck@gmail.com
State New
Headers show
Series [FFmpeg-devel] avdevice/gdigrab: Memory leak if BitBlt return false. | 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

dont.buck@gmail.com Oct. 22, 2020, 1:23 p.m. UTC
From: walle <dont.buck@gmail.com>

lock screen or other permission notification in win7 or
higher windows version would case BitBlt return false,
and gdigrab_read_packet will return AVERROR(EIO) and do nothing to
allocated packet data, then memory leak happend. It's necessary to
release packet data before return from gdigrab_read_packet.
---
 libavdevice/gdigrab.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Andreas Rheinhardt Oct. 22, 2020, 1:52 p.m. UTC | #1
dont.buck@gmail.com:
> From: walle <dont.buck@gmail.com>
> 
> lock screen or other permission notification in win7 or
> higher windows version would case BitBlt return false,
> and gdigrab_read_packet will return AVERROR(EIO) and do nothing to
> allocated packet data, then memory leak happend. It's necessary to
> release packet data before return from gdigrab_read_packet.
> ---
>  libavdevice/gdigrab.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
> index f4444406fa..b69494c98d 100644
> --- a/libavdevice/gdigrab.c
> +++ b/libavdevice/gdigrab.c
> @@ -576,6 +576,7 @@ static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
>                  clip_rect.bottom - clip_rect.top,
>                  source_hdc,
>                  clip_rect.left, clip_rect.top, SRCCOPY | CAPTUREBLT)) {
> +        av_packet_unref(pkt);
>          WIN32_API_ERROR("Failed to capture image");
>          return AVERROR(EIO);
>      }
> 
What version did you use when encountering this leak? This leak should
have been fixed in bae8844e35147f92e612a9e0b44e939a293e5bc9.

- Andreas
dont.buck@gmail.com Oct. 23, 2020, 8:43 a.m. UTC | #2
> dont.buck@gmail.com:
> > From: walle <dont.buck@gmail.com>
> >
> > lock screen or other permission notification in win7 or
> > higher windows version would case BitBlt return false,
> > and gdigrab_read_packet will return AVERROR(EIO) and do nothing to
> > allocated packet data, then memory leak happend. It's necessary to
> > release packet data before return from gdigrab_read_packet.
> > ---
> >  libavdevice/gdigrab.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
> > index f4444406fa..b69494c98d 100644
> > --- a/libavdevice/gdigrab.c
> > +++ b/libavdevice/gdigrab.c
> > @@ -576,6 +576,7 @@ static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
> >                  clip_rect.bottom - clip_rect.top,
> >                  source_hdc,
> >                  clip_rect.left, clip_rect.top, SRCCOPY | CAPTUREBLT)) {
> > +        av_packet_unref(pkt);
> >          WIN32_API_ERROR("Failed to capture image");
> >          return AVERROR(EIO);
> >      }
> >
> What version did you use when encountering this leak? This leak should
> have been fixed in bae8844e35147f92e612a9e0b44e939a293e5bc9.

Your reply is really useful, thanks, I'm using the old 3.4.7 version. And would you please tell me how to reply the email with "> " ahead of each line, I'm using an email client and have to add them manually.



dont.buck@gmail.com
 
From: Andreas Rheinhardt
Date: 2020-10-22 21:52
To: ffmpeg-devel
Subject: Re: [FFmpeg-devel] [PATCH] avdevice/gdigrab: Memory leak if BitBlt return false.
dont.buck@gmail.com:
> From: walle <dont.buck@gmail.com>
> 
> lock screen or other permission notification in win7 or
> higher windows version would case BitBlt return false,
> and gdigrab_read_packet will return AVERROR(EIO) and do nothing to
> allocated packet data, then memory leak happend. It's necessary to
> release packet data before return from gdigrab_read_packet.
> ---
>  libavdevice/gdigrab.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
> index f4444406fa..b69494c98d 100644
> --- a/libavdevice/gdigrab.c
> +++ b/libavdevice/gdigrab.c
> @@ -576,6 +576,7 @@ static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
>                  clip_rect.bottom - clip_rect.top,
>                  source_hdc,
>                  clip_rect.left, clip_rect.top, SRCCOPY | CAPTUREBLT)) {
> +        av_packet_unref(pkt);
>          WIN32_API_ERROR("Failed to capture image");
>          return AVERROR(EIO);
>      }
> 
What version did you use when encountering this leak? This leak should
have been fixed in bae8844e35147f92e612a9e0b44e939a293e5bc9.
 
- Andreas
Andreas Rheinhardt Oct. 24, 2020, 6:13 a.m. UTC | #3
dont.buck@gmail.com:
>> dont.buck@gmail.com:
>>> From: walle <dont.buck@gmail.com>
>>>
>>> lock screen or other permission notification in win7 or
>>> higher windows version would case BitBlt return false,
>>> and gdigrab_read_packet will return AVERROR(EIO) and do nothing to
>>> allocated packet data, then memory leak happend. It's necessary to
>>> release packet data before return from gdigrab_read_packet.
>>> ---
>>>  libavdevice/gdigrab.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
>>> index f4444406fa..b69494c98d 100644
>>> --- a/libavdevice/gdigrab.c
>>> +++ b/libavdevice/gdigrab.c
>>> @@ -576,6 +576,7 @@ static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
>>>                  clip_rect.bottom - clip_rect.top,
>>>                  source_hdc,
>>>                  clip_rect.left, clip_rect.top, SRCCOPY | CAPTUREBLT)) {
>>> +        av_packet_unref(pkt);
>>>          WIN32_API_ERROR("Failed to capture image");
>>>          return AVERROR(EIO);
>>>      }
>>>
>> What version did you use when encountering this leak? This leak should
>> have been fixed in bae8844e35147f92e612a9e0b44e939a293e5bc9.
> 
> Your reply is really useful, thanks, I'm using the old 3.4.7 version. And would you please tell me how to reply the email with "> " ahead of each line, I'm using an email client and have to add them manually.
> 
> 

If your email client doesn't add them when you just reply to a mail,
then it seems that your email client is either misconfigured or shit. I
can't help you with that as I have never used Foxmail. It's also not
really something for this mailing list.

- Andreas
diff mbox series

Patch

diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
index f4444406fa..b69494c98d 100644
--- a/libavdevice/gdigrab.c
+++ b/libavdevice/gdigrab.c
@@ -576,6 +576,7 @@  static int gdigrab_read_packet(AVFormatContext *s1, AVPacket *pkt)
                 clip_rect.bottom - clip_rect.top,
                 source_hdc,
                 clip_rect.left, clip_rect.top, SRCCOPY | CAPTUREBLT)) {
+        av_packet_unref(pkt);
         WIN32_API_ERROR("Failed to capture image");
         return AVERROR(EIO);
     }