Skip to content

Commit 3dfb19c

Browse files
committed
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).
1 parent 4f30857 commit 3dfb19c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

tools/hsmtool.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ static void get_words(struct words **words) {
448448
if (errno == ERANGE || (errno != 0 && val == 0) || endptr == selected || val < 0 || val >= ARRAY_SIZE(languages))
449449
errx(ERROR_USAGE, "Invalid language selection, select one from the list [0-6].");
450450

451+
free(selected);
451452
bip39_get_wordlist(languages[val].abbr, words);
452453
}
453454

@@ -610,6 +611,8 @@ static int check_hsm(const char *hsm_secret_path)
610611
errx(ERROR_KEYDERIV, "resulting hsm_secret did not match");
611612

612613
printf("OK\n");
614+
615+
free(passphrase);
613616
return 0;
614617
}
615618

0 commit comments

Comments
 (0)