From 2b24b003249a9ec40c8bae77ac3a7d2343a6273b Mon Sep 17 00:00:00 2001 From: jmjatlanta Date: Thu, 3 Aug 2017 15:04:12 -0500 Subject: [PATCH] Cleanup of after free --- repo/config/config.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/repo/config/config.c b/repo/config/config.c index 19f7cee..a94805e 100644 --- a/repo/config/config.c +++ b/repo/config/config.c @@ -97,12 +97,18 @@ int ipfs_repo_config_init(struct RepoConfig* config, unsigned int num_bits_for_k while (counter < 5) { if (counter > 0) { //TODO: This shouldn't be here, but it was the only way to cleanup. Need to find a better way... - if (config->identity->private_key.public_key_der != NULL) + if (config->identity->private_key.public_key_der != NULL) { free(config->identity->private_key.public_key_der); - if (config->identity->private_key.der != NULL) + config->identity->private_key.public_key_der = NULL; + } + if (config->identity->private_key.der != NULL) { free(config->identity->private_key.der); - if (config->identity->peer != NULL) + config->identity->private_key.der = NULL; + } + if (config->identity->peer != NULL) { libp2p_peer_free(config->identity->peer); + config->identity->peer = NULL; + } } if (!repo_config_identity_init(config->identity, num_bits_for_keypair)) return 0;