From: Dmitry Antipov Date: Wed, 29 Jun 2016 04:46:59 +0000 (+0300) Subject: Avoid possible NULL pointer dereference found by GCC 6.1.1 X-Git-Tag: emacs-26.0.90~1840^2~144 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4a2a1eba09e5bbc37b853733708feae17f1425f5;p=emacs.git 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. --- 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;