add: if (name->s[name->len]){ host_copy=pkg_malloc( name->len+1 ); if (!host_copy) { LOG(L_NOTICE, "ERROR: update_sock_struct_from_via:" " not enough memory\n");
context: int update_sock_struct_from_via( union sockaddr_union* to,								 struct via_body* via ){	struct hostent* he;	char *host_copy;	str* name;	unsigned short port;#ifdef DNS_IP_HACK	int err;	unsigned int ip;#endif	if (via->received){		DBG("update_sock_struct_from_via: using 'received'\n");		name=&(via->received->value);		/* making sure that we won't do SRV lookup on "received"		 * (possible if no DNS_IP_HACK is used)*/		port=via->port?via->port:SIP_PORT; 	}else{		DBG("update_sock_struct_from_via: using via host\n");		name=&(via->host);		port=via->port;	}#ifdef DNS_IP_HACK	ip=str2ip((unsigned char*)name->s, name->len,&err);	if (err==0){		to->sin.sin_family=AF_INET;		to->sin.sin_port=(via->port)?htons(via->port): htons(SIP_PORT);		memcpy(&to->sin.sin_addr, (char*)&ip, 4);	}else#endif	{		/* we do now a malloc/memcpy because gethostbyname loves \0-terminated 		   strings; -jiri 		   but only if host is not null terminated		   (host.s[len] will always be ok for a via)           BTW: when is via->host.s non null terminated? tm copy?		   - andrei 			Yes -- it happened on generating a 408 by TM; -jiri		*/		if (name->s[name->len]){			host_copy=pkg_malloc( name->len+1 );			if (!host_copy) {				LOG(L_NOTICE, "ERROR: update_sock_struct_from_via:"								" not enough memory\n");				return -1;			}			memcpy(host_copy, name->s, name->len );			host_copy[name->len]=0;			DBG("update_sock_struct_from_via: trying SRV lookup\n");			he=sip_resolvehost(host_copy, &port);						pkg_free( host_copy );		}else{			DBG("update_sock_struct_from_via: trying SRV lookup\n");			he=sip_resolvehost(name->s, &port);		}				if (he==0){			LOG(L_NOTICE, "ERROR:forward_reply:resolve_host(%s) failure\n",					name->s);			return -1;		}		hostent2su(to, he, 0, htons(port));	}	return 1;}