Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
tools: fix memory leaks in hsmtool
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
morehouse authored and cdecker committed Jun 7, 2023
1 parent e457681 commit debec7d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tools/hsmtool.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit debec7d

Please sign in to comment.