In function __apn_connect in apn.c a while loop is used to traverse through all the results getaddrinfo returns. However, 'addrinfo' is used as iterator. If more than just the first element is traversed before a connection is established, freeaddinfo just past the loop will try to 'free' the wrong list as 'addrinfo' has changed value and might effectively be NULL.
In function __apn_connect in apn.c a while loop is used to traverse through all the results getaddrinfo returns. However, 'addrinfo' is used as iterator. If more than just the first element is traversed before a connection is established, freeaddinfo just past the loop will try to 'free' the wrong list as 'addrinfo' has changed value and might effectively be NULL.