adobkin / libcapn

A simple C Library for interact with the Apple Push Notification Service (APNs)
MIT License
100 stars 37 forks source link

apn.c: 630: freeaddrinfo fails when first getaddrinfo result does not result in connection establishment #40

Open janknepper opened 7 years ago

janknepper commented 7 years ago

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.