From: Alexander Gramiak Date: Sat, 13 Apr 2019 22:05:21 +0000 (-0600) Subject: Fix segmentation fault with gdk_monitor_get_model (Bug#35259) X-Git-Tag: emacs-27.0.90~3259^2~4 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=7308c2edfbd600e19685bf2cde099e46be3398c8;p=emacs.git Fix segmentation fault with gdk_monitor_get_model (Bug#35259) * src/frame.c (free_monitors): Check if NULL before freeing. * src/xfns.c: (x-display-monitor-attributes-list): Check if NULL before copying. --- diff --git a/src/frame.c b/src/frame.c index 192ef4244fb..22a3996af7f 100644 --- a/src/frame.c +++ b/src/frame.c @@ -5670,7 +5670,8 @@ free_monitors (struct MonitorInfo *monitors, int n_monitors) { int i; for (i = 0; i < n_monitors; ++i) - xfree (monitors[i].name); + if (monitors[i].name) + xfree (monitors[i].name); xfree (monitors); } # endif diff --git a/src/xfns.c b/src/xfns.c index 13f66f07183..dd1d8993f5e 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -5030,7 +5030,8 @@ Internal use only, use `display-monitor-attributes-list' instead. */) mi->mm_height = height_mm; #if GTK_CHECK_VERSION (3, 22, 0) - mi->name = xstrdup (gdk_monitor_get_model (monitor)); + if (gdk_monitor_get_model (monitor)) + mi->name = xstrdup (gdk_monitor_get_model (monitor)); #elif GTK_CHECK_VERSION (2, 14, 0) mi->name = gdk_screen_get_monitor_plug_name (gscreen, i); #endif