From 4a2a1eba09e5bbc37b853733708feae17f1425f5 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 29 Jun 2016 07:46:59 +0300 Subject: [PATCH] Avoid possible NULL pointer dereference found by GCC 6.1.1 * src/xfns.c (x_get_monitor_attributes_xrandr): Always check the value returned by XRRGetOutputInfo. --- src/xfns.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xfns.c b/src/xfns.c index 1120c330e8b..265eb6c65ac 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -4295,8 +4295,8 @@ x_get_monitor_attributes_xrandr (struct x_display_info *dpyinfo) { XRROutputInfo *info = XRRGetOutputInfo (dpy, resources, resources->outputs[i]); - Connection conn = info ? info->connection : RR_Disconnected; - RRCrtc id = info ? info->crtc : None; + if (!info) + continue; if (strcmp (info->name, "default") == 0) { @@ -4307,9 +4307,9 @@ x_get_monitor_attributes_xrandr (struct x_display_info *dpyinfo) return Qnil; } - if (conn != RR_Disconnected && id != None) + if (info->connection != RR_Disconnected && info->crtc != None) { - XRRCrtcInfo *crtc = XRRGetCrtcInfo (dpy, resources, id); + XRRCrtcInfo *crtc = XRRGetCrtcInfo (dpy, resources, info->crtc); struct MonitorInfo *mi = &monitors[i]; XRectangle workarea_r; -- 2.39.2