ffmpeg | branch: master | Moritz Barsnick <[email protected]> | Wed Aug  5 
14:06:53 2020 +0200| [2250dc40443a2b1e54a8fbcaae9402fcaa1538dd] | committer: 
Andriy Gelman

avdevice/xcbgrab: check return values of xcb query functions

Fixes #7312, segmentation fault on close of X11 server

xcb_query_pointer_reply() and xcb_get_geometry_reply() can return NULL
if e.g. the X server closes or the connection is lost. This needs to
be checked in order to cleanly exit, because the returned pointers are
dereferenced later.

Signed-off-by: Moritz Barsnick <[email protected]>
Reviewed-by: Andriy Gelman <[email protected]>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2250dc40443a2b1e54a8fbcaae9402fcaa1538dd
---

 libavdevice/xcbgrab.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c
index 6f6b2dbf15..8ef2a30d02 100644
--- a/libavdevice/xcbgrab.c
+++ b/libavdevice/xcbgrab.c
@@ -425,7 +425,16 @@ static int xcbgrab_read_packet(AVFormatContext *s, 
AVPacket *pkt)
         pc  = xcb_query_pointer(c->conn, c->screen->root);
         gc  = xcb_get_geometry(c->conn, c->screen->root);
         p   = xcb_query_pointer_reply(c->conn, pc, NULL);
+        if (!p) {
+            av_log(s, AV_LOG_ERROR, "Failed to query xcb pointer\n");
+            return AVERROR_EXTERNAL;
+        }
         geo = xcb_get_geometry_reply(c->conn, gc, NULL);
+        if (!geo) {
+            av_log(s, AV_LOG_ERROR, "Failed to get xcb geometry\n");
+            free(p);
+            return AVERROR_EXTERNAL;
+        }
     }
 
     if (c->follow_mouse && p->same_screen)

_______________________________________________
ffmpeg-cvslog mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to