summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/lib/bind/irs/gai_strerror.c
diff options
context:
space:
mode:
authordougb <dougb@FreeBSD.org>2006-12-10 07:09:56 +0000
committerdougb <dougb@FreeBSD.org>2006-12-10 07:09:56 +0000
commitf5d31f05bda6a88f1513a06d3fd67e6fbaa0688e (patch)
treed7fa0e61cadfdb3b3752a55401049f2294a7cfaf /contrib/bind9/lib/bind/irs/gai_strerror.c
parent4a3a088a0b6ffaf0dd6b740dbe537d5a082825d5 (diff)
downloadFreeBSD-src-f5d31f05bda6a88f1513a06d3fd67e6fbaa0688e.zip
FreeBSD-src-f5d31f05bda6a88f1513a06d3fd67e6fbaa0688e.tar.gz
Vendor import of BIND 9.3.3
Diffstat (limited to 'contrib/bind9/lib/bind/irs/gai_strerror.c')
-rw-r--r--contrib/bind9/lib/bind/irs/gai_strerror.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/contrib/bind9/lib/bind/irs/gai_strerror.c b/contrib/bind9/lib/bind/irs/gai_strerror.c
index 6aeaaa1..0492f8f 100644
--- a/contrib/bind9/lib/bind/irs/gai_strerror.c
+++ b/contrib/bind9/lib/bind/irs/gai_strerror.c
@@ -66,18 +66,26 @@ gai_strerror(int ecode) {
#ifdef DO_PTHREADS
if (!once) {
- pthread_mutex_lock(&lock);
- if (!once++)
- pthread_key_create(&key, free);
- pthread_mutex_unlock(&lock);
+ if (pthread_mutex_lock(&lock) != 0)
+ goto unknown;
+ if (!once) {
+ if (pthread_key_create(&key, free) != 0)
+ goto unknown;
+ once = 1;
+ }
+ if (pthread_mutex_unlock(&lock) != 0)
+ goto unknown;
}
buf = pthread_getspecific(key);
if (buf == NULL) {
buf = malloc(EAI_BUFSIZE);
if (buf == NULL)
- return ("unknown error");
- pthread_setspecific(key, buf);
+ goto unknown;
+ if (pthread_setspecific(key, buf) != 0) {
+ free(buf);
+ goto unknown;
+ }
}
#endif
/*
@@ -86,4 +94,9 @@ gai_strerror(int ecode) {
*/
sprintf(buf, "%s: %d", gai_errlist[gai_nerr - 1], ecode);
return (buf);
+
+#ifdef DO_PTHREADS
+ unknown:
+ return ("unknown error");
+#endif
}
OpenPOWER on IntegriCloud