diff mbox

[FFmpeg-devel] avdevice/xcbgrab: Handle reply and error properly

Message ID 20191119135931601.KMJV.44544.ppp.dion.ne.jp@dmta0002.auone-net.jp
State Accepted
Commit 12bbfc4ccaa150e06895691049fa2ea33385d210
Headers show

Commit Message

Kusanagi Kouichi Nov. 19, 2019, 1:59 p.m. UTC
Fix a NULL dereference and leaks.

Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
---
 libavdevice/xcbgrab.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Kusanagi Kouichi Dec. 3, 2019, 1:24 p.m. UTC | #1
On 2019-11-19 22:59:30 +0900, Kusanagi Kouichi wrote:
> Fix a NULL dereference and leaks.
> 
> Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
> ---
>  libavdevice/xcbgrab.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
> index b7e689343e..063fecf838 100644
> --- a/libavdevice/xcbgrab.c
> +++ b/libavdevice/xcbgrab.c
> @@ -168,6 +168,7 @@ static int xcbgrab_frame(AVFormatContext *s, AVPacket *pkt)
>                 "sequence:%u resource_id:%u minor_code:%u major_code:%u.\n",
>                 e->response_type, e->error_code,
>                 e->sequence, e->resource_id, e->minor_code, e->major_code);
> +        free(e);
>          return AVERROR(EACCES);
>      }
>  
> @@ -276,6 +277,7 @@ static int xcbgrab_frame_shm(AVFormatContext *s, AVPacket *pkt)
>                 e->response_type, e->error_code,
>                 e->sequence, e->resource_id, e->minor_code, e->major_code);
>  
> +        free(e);
>          return AVERROR(EACCES);
>      }
>  
> @@ -537,6 +539,8 @@ static int create_stream(AVFormatContext *s)
>  
>      gc  = xcb_get_geometry(c->conn, c->screen->root);
>      geo = xcb_get_geometry_reply(c->conn, gc, NULL);
> +    if (!geo)
> +        return AVERROR_EXTERNAL;
>  
>      if (c->x + c->width > geo->width ||
>          c->y + c->height > geo->height) {
> @@ -546,6 +550,7 @@ static int create_stream(AVFormatContext *s)
>                 c->width, c->height,
>                 c->x, c->y,
>                 geo->width, geo->height);
> +        free(geo);
>          return AVERROR(EINVAL);
>      }
>  
> -- 
> 2.24.0
> 

ping
Marton Balint Dec. 3, 2019, 8:15 p.m. UTC | #2
On Tue, 3 Dec 2019, Kusanagi Kouichi wrote:

> On 2019-11-19 22:59:30 +0900, Kusanagi Kouichi wrote:
>> Fix a NULL dereference and leaks.
>> 
>> Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
>> ---
>>  libavdevice/xcbgrab.c | 5 +++++
>>  1 file changed, 5 insertions(+)
>> 
>> diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
>> index b7e689343e..063fecf838 100644
>> --- a/libavdevice/xcbgrab.c
>> +++ b/libavdevice/xcbgrab.c
>> @@ -168,6 +168,7 @@ static int xcbgrab_frame(AVFormatContext *s, AVPacket *pkt)
>>                 "sequence:%u resource_id:%u minor_code:%u major_code:%u.\n",
>>                 e->response_type, e->error_code,
>>                 e->sequence, e->resource_id, e->minor_code, e->major_code);
>> +        free(e);
>>          return AVERROR(EACCES);
>>      }
>> 
>> @@ -276,6 +277,7 @@ static int xcbgrab_frame_shm(AVFormatContext *s, AVPacket *pkt)
>>                 e->response_type, e->error_code,
>>                 e->sequence, e->resource_id, e->minor_code, e->major_code);
>> 
>> +        free(e);
>>          return AVERROR(EACCES);
>>      }
>> 
>> @@ -537,6 +539,8 @@ static int create_stream(AVFormatContext *s)
>>
>>      gc  = xcb_get_geometry(c->conn, c->screen->root);
>>      geo = xcb_get_geometry_reply(c->conn, gc, NULL);
>> +    if (!geo)
>> +        return AVERROR_EXTERNAL;
>>
>>      if (c->x + c->width > geo->width ||
>>          c->y + c->height > geo->height) {
>> @@ -546,6 +550,7 @@ static int create_stream(AVFormatContext *s)
>>                 c->width, c->height,
>>                 c->x, c->y,
>>                 geo->width, geo->height);
>> +        free(geo);
>>          return AVERROR(EINVAL);
>>      }
>> 
>> -- 
>> 2.24.0
>> 
>
> ping

Applied, thanks.

Regards,
Marton
diff mbox

Patch

diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index b7e689343e..063fecf838 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -168,6 +168,7 @@  static int xcbgrab_frame(AVFormatContext *s, AVPacket *pkt)
                "sequence:%u resource_id:%u minor_code:%u major_code:%u.\n",
                e->response_type, e->error_code,
                e->sequence, e->resource_id, e->minor_code, e->major_code);
+        free(e);
         return AVERROR(EACCES);
     }
 
@@ -276,6 +277,7 @@  static int xcbgrab_frame_shm(AVFormatContext *s, AVPacket *pkt)
                e->response_type, e->error_code,
                e->sequence, e->resource_id, e->minor_code, e->major_code);
 
+        free(e);
         return AVERROR(EACCES);
     }
 
@@ -537,6 +539,8 @@  static int create_stream(AVFormatContext *s)
 
     gc  = xcb_get_geometry(c->conn, c->screen->root);
     geo = xcb_get_geometry_reply(c->conn, gc, NULL);
+    if (!geo)
+        return AVERROR_EXTERNAL;
 
     if (c->x + c->width > geo->width ||
         c->y + c->height > geo->height) {
@@ -546,6 +550,7 @@  static int create_stream(AVFormatContext *s)
                c->width, c->height,
                c->x, c->y,
                geo->width, geo->height);
+        free(geo);
         return AVERROR(EINVAL);
     }