From: Alex Riesen Date: Wed, 29 Apr 2009 21:55:01 GMT Subject: Re: [PATCH] Workaround for ai_canonname sometimes coming back as null Message-ID: <81b0412b0904291455n47f83e9ftcbdec0ff1c0ea03@mail.gmail.com> In-Reply-To: <9C355DCC-0240-4B9E-83CA-083B51C2E34C@gmail.com> 2009/4/29 Augie Fackler : > @@ -459,7 +459,10 @@ static void parse_extra_args(char *extra_args, int > buflen) >                                inet_ntop(AF_INET, &sin_addr->sin_addr, >                                          addrbuf, sizeof(addrbuf)); >                                free(canon_hostname); > -                               canon_hostname = xstrdup(ai->ai_canonname); > +                               if (ai->ai_canonname) > +                                       canon_hostname = > xstrdup(ai->ai_canonname); > +                               else > +                                       canon_hostname = "unknown"; This last line will crash some lines down, when canon_hostname is free'd: inet_ntop(hent->h_addrtype, &sa.sin_addr, addrbuf, sizeof(addrbuf)); free(canon_hostname); /* CRASH */ canon_hostname = xstrdup(hent->h_name); free(ip_address);