xcb_query_pointer_reply() and xcb_get_geometry_reply() return NULL when the display drops. This needs to be checked in order to cleanly exit, because the returned pointers are dereferenced later.
Signed-off-by: Moritz Barsnick <barsn...@gmx.net> --- libavdevice/xcbgrab.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/libavdevice/xcbgrab.c b/libavdevice/xcbgrab.c index 6d142abd4f..609445918b 100644 --- a/libavdevice/xcbgrab.c +++ b/libavdevice/xcbgrab.c @@ -404,7 +404,17 @@ 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(c, AV_LOG_ERROR, "Could not get xcb pointer\n"); + ret = AVERROR(EIO); + goto fail; + } geo = xcb_get_geometry_reply(c->conn, gc, NULL); + if (!geo) { + av_log(c, AV_LOG_ERROR, "Could not get xcb geometry\n"); + ret = AVERROR_EOF; + goto fail; + } } if (c->follow_mouse && p->same_screen) @@ -425,8 +435,9 @@ static int xcbgrab_read_packet(AVFormatContext *s, AVPacket *pkt) xcbgrab_draw_mouse(s, pkt, p, geo); #endif - free(p); - free(geo); +fail: + av_free(p); + av_free(geo); return ret; } @@ -537,6 +548,10 @@ 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) { + av_log(c, AV_LOG_ERROR, "Could not get xcb geometry\n"); + return AVERROR(EIO); + } if (c->x + c->width > geo->width || c->y + c->height > geo->height) { -- 2.14.4 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel