Fix resource leaks found by GCC -fanalyzer
authorKirill Isakov <bootctl@gmail.com>
Sun, 17 Apr 2022 19:37:38 +0000 (01:37 +0600)
committerKirill Isakov <bootctl@gmail.com>
Tue, 26 Apr 2022 18:52:37 +0000 (00:52 +0600)
src/keys.c
src/multicast_device.c

index ac99ac4..84bd071 100644 (file)
@@ -134,6 +134,7 @@ ecdsa_t *read_ecdsa_private_key(splay_tree_t *config_tree, char **keyfile) {
        if(fstat(fileno(fp), &s)) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Could not stat Ed25519 private key file `%s': %s'", fname, strerror(errno));
                free(fname);
+               fclose(fp);
                return false;
        }
 
@@ -268,6 +269,7 @@ rsa_t *read_rsa_private_key(splay_tree_t *config_tree, char **keyfile) {
        if(fstat(fileno(fp), &s)) {
                logger(DEBUG_ALWAYS, LOG_ERR, "Could not stat RSA private key file `%s': %s'", fname, strerror(errno));
                free(fname);
+               fclose(fp);
                return NULL;
        }
 
index 79239a1..3dba7f7 100644 (file)
@@ -144,6 +144,7 @@ static bool setup_device(void) {
 
        logger(DEBUG_ALWAYS, LOG_INFO, "%s is a %s", device, device_info);
 
+       free(host);
        return true;
 
 error: