Skip to content

Conversation

@micrictor
Copy link

@micrictor micrictor commented Nov 9, 2025

Passing null to freeaddrinfo is undefined behaviour. While glibc and uClibc both handle it safely, musl does not, so a bad nodename or servname causes a segfault.

This change ensures that the ai_list is non-null before trying to free it in the connect function. The check already exists for listen

In musl and glibc this condition will never be met, meaning freeaddrinfo will never actually be ran. There's no possibility for errors to be returned after memory allocation occurs in those implementations either, so there's no remaining risk of memory leaks.

In uClibc, there are some code paths where errors occur after memory is allocated, and this still guarantees it will get freed.

Passing null to freeaddrinfo is undefined behaviour. While glibc and uClibc both handle it safely,
musl does not, so a bad nodename or servname causes a segfault.

This change ensures that the ai_list is non-null before trying to free it. In musl and glibc this
condition will never be met, but there are some paths for it to be met in uClibc.
@cla-bot
Copy link

cla-bot bot commented Nov 9, 2025

We require contributors to sign our Contributor License Agreement. In order for us to review and merge your code, please fill https://forms.gle/5635zjphDo5JEJQSA to get added. Your document will be manually checked by the maintainer. Be patient...

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