getservbyport_r: fix wrong result if getnameinfo fails with EAI_OVERFLOW
[musl] / src / network / h_errno.c
index 8677a92..638f771 100644 (file)
@@ -1,7 +1,11 @@
 #include <netdb.h>
 #include "pthread_impl.h"
 
+#undef h_errno
+int h_errno;
+
 int *__h_errno_location(void)
 {
+       if (!__pthread_self()->stack) return &h_errno;
        return &__pthread_self()->h_errno_val;
 }