Skip to content
Snippets Groups Projects
Commit 93b74640 authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

knotc: fix memory leak when installing the key

Change-Id: I571cc82f393d526e43ba17ade19f57ce067b5c52
parent dccf55bc
No related branches found
No related tags found
No related merge requests found
......@@ -536,19 +536,11 @@ int main(int argc, char **argv)
/* Fill defaults. */
if (!r_addr) r_addr = "127.0.0.1";
if (r_port < 0) r_port = REMOTE_DPORT;
}
/* Create empty key. */
if (r_key.name) {
ctl_if->key = malloc(sizeof(knot_tsig_key_t));
if (ctl_if->key) {
memcpy(ctl_if->key, &r_key, sizeof(knot_tsig_key_t));
}
}
} else {
if (r_key.name) {
knot_tsig_key_free(ctl_if->key);
ctl_if->key = &r_key;
}
/* Install the key. */
if (r_key.name) {
ctl_if->key = &r_key;
}
/* Override from command line. */
......@@ -572,7 +564,7 @@ int main(int argc, char **argv)
int rc = cmd->cb(argc - optind - 1, argv + optind + 1, flags);
/* Finish */
knot_tsig_key_free(&r_key); /* Not cleaned by config deinit. */
knot_tsig_key_free(&r_key);
log_close();
free(config_fn);
free(default_config);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment