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 ssh_kex2 function #461

Closed
wants to merge 1 commit into from

Conversation

xerxes235
Copy link

This pull request addresses a memory leak issue within the ssh_kex2 function. The function calls kex_names_cat to concatenate key exchange algorithm names, which returns dynamically allocated memory. According to the design of kex_names_cat, the caller is responsible for freeing this memory.

However, in the original implementation of ssh_kex2, the allocated memory by kex_names_cat (assigned to the pointer s) was not freed before the function returned. This oversight led to a memory leak, as the pointer to the allocated memory was lost upon function exit, with no way to reclaim or free it later.

The proposed change introduces a free(s) call just before the end of the ssh_kex2 function, ensuring that the dynamically allocated memory is correctly deallocated. This change prevents the memory leak, ensuring that all allocated resources within ssh_kex2 are properly managed and released.

Fix memory leak in ssh_kex2 by freeing result of kex_names_cat
@djmdjm
Copy link
Contributor

djmdjm commented Jan 8, 2024

AFAIK this doesn't make sense after a72833d

@djmdjm djmdjm closed this Jan 8, 2024
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.

2 participants