From 2f9af5d673891e566b306bf4e00970e3df0ea01d Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Fri, 1 Nov 2013 20:59:51 -0700 Subject: [PATCH] Fix memory leaks found using valgrind A harmless failure to cleanup the config structure before exiting keydctl and a more major (small, but key runs for a long period of time) leak of the search string for fetching a key by text string in keyd. --- keyd.c | 1 + keydctl.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/keyd.c b/keyd.c index 4528c96..21d3bdb 100644 --- a/keyd.c +++ b/keyd.c @@ -275,6 +275,7 @@ int sock_do(int fd) write(fd, &storebuf.offset, sizeof(storebuf.offset)); } + free(search); } break; case KEYD_CMD_STORE: diff --git a/keydctl.c b/keydctl.c index 11e5e8f..5a2ac21 100644 --- a/keydctl.c +++ b/keydctl.c @@ -220,6 +220,7 @@ int main(int argc, char *argv[]) configfile = NULL; if ((argc - optind) < 1) { + cleanupconfig(); usage(); } else if (!strcmp("check", argv[optind])) { /* Just do the connect and close quietly */ @@ -235,9 +236,11 @@ int main(int argc, char *argv[]) keyd_do_command(KEYD_CMD_QUIT, NULL, 0); keyd_close(); } else { + cleanupconfig(); usage(); } + cleanupconfig(); exit(EXIT_SUCCESS); } -- 2.39.2