From: Jonathan McDowell Date: Sat, 2 Nov 2013 03:59:51 +0000 (-0700) Subject: Fix memory leaks found using valgrind X-Git-Tag: onak-0.4.3~50 X-Git-Url: https://the.earth.li/gitweb/?a=commitdiff_plain;h=2f9af5d673891e566b306bf4e00970e3df0ea01d;p=onak.git 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. --- 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); }