aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Gramiak2019-04-13 16:05:21 -0600
committerAlexander Gramiak2019-04-13 16:14:47 -0600
commit7308c2edfbd600e19685bf2cde099e46be3398c8 (patch)
tree630a4a10015e8a1841c90a2165a7ef8bd69cebf5
parent894e1420829b24d4a6befcd09e285ea9e52e57f6 (diff)
downloademacs-7308c2edfbd600e19685bf2cde099e46be3398c8.tar.gz
emacs-7308c2edfbd600e19685bf2cde099e46be3398c8.zip
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.
-rw-r--r--src/frame.c3
-rw-r--r--src/xfns.c3
2 files changed, 4 insertions, 2 deletions
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)
5670{ 5670{
5671 int i; 5671 int i;
5672 for (i = 0; i < n_monitors; ++i) 5672 for (i = 0; i < n_monitors; ++i)
5673 xfree (monitors[i].name); 5673 if (monitors[i].name)
5674 xfree (monitors[i].name);
5674 xfree (monitors); 5675 xfree (monitors);
5675} 5676}
5676# endif 5677# 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. */)
5030 mi->mm_height = height_mm; 5030 mi->mm_height = height_mm;
5031 5031
5032#if GTK_CHECK_VERSION (3, 22, 0) 5032#if GTK_CHECK_VERSION (3, 22, 0)
5033 mi->name = xstrdup (gdk_monitor_get_model (monitor)); 5033 if (gdk_monitor_get_model (monitor))
5034 mi->name = xstrdup (gdk_monitor_get_model (monitor));
5034#elif GTK_CHECK_VERSION (2, 14, 0) 5035#elif GTK_CHECK_VERSION (2, 14, 0)
5035 mi->name = gdk_screen_get_monitor_plug_name (gscreen, i); 5036 mi->name = gdk_screen_get_monitor_plug_name (gscreen, i);
5036#endif 5037#endif