@miconda
have you checked that setting 0 in place of ] is not having other side effects? I didn't notice any restore.
Yes, hp - is a pointer to pkg_malloc-ed hostname variable, this var is freed right after getaddrinfo and not used any more. I tested this patch localy, work as expected.