tools: fix memory leaks in hsmtool

Detected by ASan in test_hsmtool_generatehsm:

==58698==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 120 byte(s) in 1 object(s) allocated from:
    #0 0x4e6247 in malloc
    #1 0x7f078452d672 in getdelim

SUMMARY: AddressSanitizer: 120 byte(s) leaked in 1 allocation(s).
This commit is contained in:
Matt Morehouse 2023-06-06 10:06:04 -05:00 committed by Christian Decker
parent e457681f3a
commit debec7d6e9
1 changed files with 3 additions and 0 deletions

View File

@ -448,6 +448,7 @@ static void get_words(struct words **words) {
if (errno == ERANGE || (errno != 0 && val == 0) || endptr == selected || val < 0 || val >= ARRAY_SIZE(languages))
errx(ERROR_USAGE, "Invalid language selection, select one from the list [0-6].");
free(selected);
bip39_get_wordlist(languages[val].abbr, words);
}
@ -610,6 +611,8 @@ static int check_hsm(const char *hsm_secret_path)
errx(ERROR_KEYDERIV, "resulting hsm_secret did not match");
printf("OK\n");
free(passphrase);
return 0;
}