]> the.earth.li Git - onak.git/commitdiff
Fix memory leaks found using valgrind
authorJonathan McDowell <noodles@earth.li>
Sat, 2 Nov 2013 03:59:51 +0000 (20:59 -0700)
committerJonathan McDowell <noodles@earth.li>
Sat, 2 Nov 2013 03:59:51 +0000 (20:59 -0700)
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
keydctl.c

diff --git a/keyd.c b/keyd.c
index 4528c96fef874963542b56eccac17896887ab493..21d3bdbe2f35dabd020f3f74fde8ea798414bba9 100644 (file)
--- 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:
index 11e5e8f3ae4fdfe0aaba40a8f20afab618a31cc5..5a2ac212b96be129cab52b173b48d8737e26757a 100644 (file)
--- 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);
 }