diff --git a/src/network.c b/src/network.c index a0c4396..7bae20b 100644 --- a/src/network.c +++ b/src/network.c @@ -251,6 +251,8 @@ CLEANUP: */ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen) { + const char *result; + assert (sa != NULL); assert (buf != NULL); assert (buflen != 0); @@ -261,7 +263,8 @@ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen) { struct sockaddr_in *sa_in = (struct sockaddr_in *) sa; - inet_ntop (AF_INET, &sa_in->sin_addr, buf, buflen); + result = inet_ntop (AF_INET, &sa_in->sin_addr, buf, + buflen); break; } case AF_INET6: @@ -269,7 +272,8 @@ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen) struct sockaddr_in6 *sa_in6 = (struct sockaddr_in6 *) sa; - inet_ntop (AF_INET6, &sa_in6->sin6_addr, buf, buflen); + result = inet_ntop (AF_INET6, &sa_in6->sin6_addr, buf, + buflen); break; } default: @@ -277,7 +281,7 @@ const char *get_ip_string (struct sockaddr *sa, char *buf, size_t buflen) return NULL; } - return buf; + return result; } /*