Skip to content

Conversation

@clarkok
Copy link
Contributor

@clarkok clarkok commented Nov 14, 2025

The current member initialization for struct GetAddrInfoState does not work as the node on the right side of the assignment refers to the member node of struct GetAddrInfoState, which is empty for debug build and uninitialized for optimized build, instead of the node the function parameter.

This results in the following getaddrinfo getting called with unexpected parameters, thus it is yielding unexpected result. I found this issue on Android, and probably this also applies to platforms other than those in the #if.

Also this change fixes a potential memory leak. When timeout is hit on line 3857, and the getaddrinfo succeeds in the end, the state->info will be assigned to the pointer of a new struct addrinfo allocated by getaddrinfo, while no one will free that. This change adds a destructor on GetAddrInfoState to manage the lifecycle of that.

@clarkok clarkok force-pushed the dev-fix-getaddrinfo_with_timeout branch from 9149e8a to 711f661 Compare November 14, 2025 17:06
@yhirose yhirose merged commit 27ee115 into yhirose:master Nov 14, 2025
25 of 31 checks passed
@yhirose
Copy link
Owner

yhirose commented Nov 14, 2025

@clarkok thanks for the bug fix!

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