Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in hkdf_expand #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

joerowell
Copy link

@joerowell joerowell commented Nov 15, 2022

At the moment hkdf_expand allocates memory on each iteration of the loop but never frees it:

for(int i = 1; i <= N; i++) {
    auto input = new block[8 + info_len + cur_T_len];
    ...
}

This means that the program leaks memory each time hkdf_expand is called.

This PR fixes this by:

  1. Moving the allocation outside of the loop. This should also make the code run faster.
  2. Freeing the memory after the loop terminates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant