From 0409469d041c3686ad34a3e694d574a49b7ff2db Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 3 Aug 2014 04:21:28 +0200 Subject: free the clipboard when exiting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/mds-clipboard.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/mds-clipboard.c b/src/mds-clipboard.c index 9d7926a..212b039 100644 --- a/src/mds-clipboard.c +++ b/src/mds-clipboard.c @@ -252,7 +252,8 @@ size_t marshal_server_size(void) */ static inline __attribute__((optimize("-O0"))) void wipe_and_free(void* s, size_t n) { - free(memset(s, 0, n)); + if (s != NULL) + free(memset(s, 0, n)); } @@ -392,6 +393,7 @@ int __attribute__((const)) reexec_failure_recover(void) int master_loop(void) { int rc = 1; + size_t i, j; while (!reexecing && !terminating) { @@ -427,8 +429,16 @@ int master_loop(void) pfail: xperror(*argv); fail: - if (rc || !reexecing) - mds_message_destroy(&received); + if (!rc && reexecing) + return 0; + mds_message_destroy(&received); + for (i = 0; i < CLIPBOARD_LEVELS; i++) + if (clipboard[i] != NULL) + { + for (j = 0; j < clipboard_used[i]; j++) + wipe_and_free(clipboard[i][j].content, clipboard[i][j].length); + free(clipboard[i]); + } return rc; } -- cgit v1.2.3-70-g09d2