diff options
author | Mattias Andrée <maandree@operamail.com> | 2014-08-03 04:21:28 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2014-08-03 04:21:28 +0200 |
commit | 0409469d041c3686ad34a3e694d574a49b7ff2db (patch) | |
tree | ddeeba638bc31025a22ce914b8684113a46b4f09 | |
parent | misc (diff) | |
download | mds-0409469d041c3686ad34a3e694d574a49b7ff2db.tar.gz mds-0409469d041c3686ad34a3e694d574a49b7ff2db.tar.bz2 mds-0409469d041c3686ad34a3e694d574a49b7ff2db.tar.xz |
free the clipboard when exiting
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | src/mds-clipboard.c | 16 |
1 files 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; } |