[Lldb-commits] [lldb] r222862 - Refactor SocketAddress::getaddrinfo - avoid calling IsValid if ::getaddrinfo has failed.

Oleksiy Vyalov ovyalov at google.com
Wed Nov 26 16:32:54 PST 2014


Author: ovyalov
Date: Wed Nov 26 18:32:54 2014
New Revision: 222862

URL: http://llvm.org/viewvc/llvm-project?rev=222862&view=rev
Log:
Refactor SocketAddress::getaddrinfo - avoid calling IsValid if ::getaddrinfo has failed.
Otherwise, IsValid crashes on assertation in GetFamilyLength.

Modified:
    lldb/trunk/source/Host/common/SocketAddress.cpp

Modified: lldb/trunk/source/Host/common/SocketAddress.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/SocketAddress.cpp?rev=222862&r1=222861&r2=222862&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/SocketAddress.cpp (original)
+++ lldb/trunk/source/Host/common/SocketAddress.cpp Wed Nov 26 18:32:54 2014
@@ -214,6 +214,8 @@ SocketAddress::getaddrinfo (const char *
                             int ai_protocol,
                             int ai_flags)
 {
+    Clear ();
+
     struct addrinfo hints;
     memset(&hints, 0, sizeof(hints));
     hints.ai_family = ai_family;
@@ -221,15 +223,17 @@ SocketAddress::getaddrinfo (const char *
     hints.ai_protocol = ai_protocol;
     hints.ai_flags = ai_flags;
 
+    bool result = false;
     struct addrinfo *service_info_list = NULL;
     int err = ::getaddrinfo (host, service, &hints, &service_info_list);
     if (err == 0 && service_info_list)
+    {
         *this = service_info_list;
-    else
-        Clear();
+        result = IsValid ();
+    }
     
     :: freeaddrinfo (service_info_list);
-    return IsValid();
+    return result;
 }
 
 





More information about the lldb-commits mailing list