summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gramiak <agrambot@gmail.com>2019-04-06 23:02:24 -0600
committerAlexander Gramiak <agrambot@gmail.com>2019-04-07 12:49:02 -0600
commita35e06bbe27c5907f56c5aeb48182d7be00d1dec (patch)
tree49206a9771c4b727e8f75449aff8c2f0077f6d4d
parent404a5470cf1b1ae5bd464aaf8fe909b86faa2e61 (diff)
downloademacs-a35e06bbe27c5907f56c5aeb48182d7be00d1dec.tar.gz
Plug memory leak in GTK x-display-monitor-attributes-list
* src/frame.c (free_monitors) [USE_GTK]: Define in the GTK case as well. * src/xfns.c (x-display-monitor-attributes-list) [USE_GTK]: Plug memory leak. * src/frame.h (MonitorInfo): Declare name as pointing to const char.
-rw-r--r--src/frame.c4
-rw-r--r--src/frame.h2
-rw-r--r--src/xfns.c7
3 files changed, 9 insertions, 4 deletions
diff --git a/src/frame.c b/src/frame.c
index d0c77149ba8..6fdb7d0cbb9 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -5662,8 +5662,8 @@ selected frame. This is useful when `make-pointer-invisible' is set. */)
#ifdef HAVE_WINDOW_SYSTEM
-# if (defined HAVE_NS \
- || (!defined USE_GTK && (defined HAVE_XINERAMA || defined HAVE_XRANDR)))
+# if (defined USE_GTK || defined HAVE_NS || defined HAVE_XINERAMA \
+ || defined HAVE_XRANDR)
void
free_monitors (struct MonitorInfo *monitors, int n_monitors)
{
diff --git a/src/frame.h b/src/frame.h
index ed62e7ace0f..b1eedf36a38 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -1648,7 +1648,7 @@ flush_frame (struct frame *f)
struct MonitorInfo {
XRectangle geom, work;
int mm_width, mm_height;
- char *name;
+ const char *name;
};
extern void free_monitors (struct MonitorInfo *monitors, int n_monitors);
diff --git a/src/xfns.c b/src/xfns.c
index f238a3daa15..9a25b00b20e 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5030,7 +5030,7 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
mi->mm_height = height_mm;
#if GTK_CHECK_VERSION (3, 22, 0)
- mi->name = g_strdup (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
@@ -5041,6 +5041,11 @@ Internal use only, use `display-monitor-attributes-list' instead. */)
primary_monitor,
monitor_frames,
source);
+#if GTK_CHECK_VERSION (2, 14, 0)
+ free_monitors (monitors, n_monitors);
+#else
+ xfree (monitors)
+#endif
unblock_input ();
#else /* not USE_GTK */