Skip to content
New issue

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

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

Already on GitHub? # to your account

fix SEGFAULT on early exit with IPv6 enabled #97

Merged
merged 3 commits into from
Feb 17, 2024

Conversation

bmork
Copy link
Contributor

@bmork bmork commented Feb 5, 2024

Some command line options, like e.g -V, will cause conserver to exit before the IPv6 address variables are initialized. Avoid the calls to freeaddrinfo() in these cases.

Some command line options, like e.g -V, will cause conserver
to exit before the IPv6 address variables are initialized.
Avoid the calls to freeaddrinfo() in these cases.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
bmork added a commit to bmork/openwrt-packages that referenced this pull request Feb 5, 2024
Add pending patch, fixing a crash when conserver exits
without starting the server.

Link: bstansell/conserver#97
Signed-off-by: Bjørn Mork <bjorn@mork.no>
bmork added a commit to bmork/openwrt-packages that referenced this pull request Feb 6, 2024
Add pending patch, fixing a crash when conserver exits
without starting the server.

Link: bstansell/conserver#97
Signed-off-by: Bjørn Mork <bjorn@mork.no>
bmork added a commit to bmork/openwrt-packages that referenced this pull request Feb 6, 2024
Add pending patch, fixing a crash when conserver exits
without starting the server.

Link: bstansell/conserver#97
Signed-off-by: Bjørn Mork <bjorn@mork.no>
struct addrinfo *bindAddr;
struct addrinfo *bindBaseAddr;
struct addrinfo *bindAddr = (struct addrinfo *)0;
struct addrinfo *bindBaseAddr = (struct addrinfo *)0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is unnecessary. These are globals, and have "static storage duration" and thus are already guaranteed to be initialized to NULL.

In section 3.5.7 of the C89 drafts available onliine:
"If an object that has static storage duration is not initialized explicitly, it is initialized implicitly as if every member that has arithmetic type were assigned 0 and every member that has pointer type were assigned a null pointer constant. "

@@ -781,8 +781,10 @@ DestroyDataStructures(void)

#if USE_IPV6
/* clean up addrinfo stucts */
freeaddrinfo(bindAddr);
freeaddrinfo(bindBaseAddr);
if ((struct addrinfo *)0 != bindAddr)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need the casts. A NULL or 0 in pointer context can be compared against a pointer of any type. See C89 section 3.2.2.3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sure. Just trying my best to match the existing code style.

@bstansell bstansell merged commit ee0fa16 into bstansell:master Feb 17, 2024
2 checks passed
bmork added a commit to bmork/openwrt-packages that referenced this pull request Feb 28, 2025
Add pending patch, fixing a crash when conserver exits
without starting the server.

Link: bstansell/conserver#97
Signed-off-by: Bjørn Mork <bjorn@mork.no>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants