Correctly handle getaddrinfo return result

The getaddrinfo function indicates failure with a non-zero return code,
but this code is not necessarily negative. On platforms like Android
where the code is positive, a failed call causes libgit2 to segfault.
Merge pull request #2582 from swansontec/master

Correctly handle getaddrinfo return result