-
Notifications
You must be signed in to change notification settings - Fork 38
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,8 +53,8 @@ int fAll = 0, fNoinit = 0, fVersion = 0, fStrip = 0, fReopen = | |
char *pcConfig = CONFIGFILE; | ||
int cMaxMemb = MAXMEMB; | ||
#if USE_IPV6 | ||
struct addrinfo *bindAddr; | ||
struct addrinfo *bindBaseAddr; | ||
struct addrinfo *bindAddr = (struct addrinfo *)0; | ||
struct addrinfo *bindBaseAddr = (struct addrinfo *)0; | ||
#else | ||
in_addr_t bindAddr = INADDR_ANY; | ||
unsigned short bindPort; | ||
|
@@ -781,8 +781,10 @@ DestroyDataStructures(void) | |
|
||
#if USE_IPV6 | ||
/* clean up addrinfo stucts */ | ||
freeaddrinfo(bindAddr); | ||
freeaddrinfo(bindBaseAddr); | ||
if ((struct addrinfo *)0 != bindAddr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, sure. Just trying my best to match the existing code style. |
||
freeaddrinfo(bindAddr); | ||
if ((struct addrinfo *)0 != bindBaseAddr) | ||
freeaddrinfo(bindBaseAddr); | ||
#else | ||
if (myAddrs != (struct in_addr *)0) | ||
free(myAddrs); | ||
|
There was a problem hiding this comment.
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. "