summaryrefslogtreecommitdiffstats
path: root/client/x11
diff options
context:
space:
mode:
Diffstat (limited to 'client/x11')
-rw-r--r--client/x11/platform.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index dc0787f0..c6b2d7de 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -2445,7 +2445,14 @@ exit:
static void get_selection_free(unsigned char *data, bool incr)
{
- if (!incr && data)
+ if (incr) {
+ /* If the clipboard was large return the memory to the system */
+ if (clipboard_data_space > 512 * 1024) {
+ free(clipboard_data);
+ clipboard_data = NULL;
+ clipboard_data_space = 0;
+ }
+ } else if (data)
XFree(data);
}