The pjsip_host_port a_name variable was being assigned to a temporary unnamed string that went out of scope immediately, leaving a_name pointing to garbage.