This is an automated email from the ASF dual-hosted git repository.

bneradt pushed a commit to branch dev-1-2-7
in repository https://gitbox.apache.org/repos/asf/trafficserver-libswoc.git

commit 7b97bcf66f28a78dcac44eb1b6f63891db71b072
Author: Alan M. Carroll <[email protected]>
AuthorDate: Mon Jun 22 14:50:09 2020 -0500

    Change IPEndpoint::port to throw instead of returning a reference to 
nullptr.
---
 code/include/swoc/swoc_ip.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/code/include/swoc/swoc_ip.h b/code/include/swoc/swoc_ip.h
index 5affe96..79dcd36 100644
--- a/code/include/swoc/swoc_ip.h
+++ b/code/include/swoc/swoc_ip.h
@@ -2069,7 +2069,7 @@ IPEndpoint::port(sockaddr *sa) {
     case AF_INET6:return reinterpret_cast<sockaddr_in6 *>(sa)->sin6_port;
   }
   // Force a failure upstream by returning a null reference.
-  return *static_cast<in_port_t *>(nullptr);
+  throw std::domain_error("sockaddr is not a valid IP address");
 }
 
 inline in_port_t

Reply via email to