From 8363ddb32da86811663d12d0b2c61a8ea2fa0eae Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Sun, 25 Feb 2007 23:46:58 +0000 Subject: [PATCH] 2140. [bug] libbind: missing unlock on pthread_key_create() failures. [RT #16654] --- CHANGES | 3 +++ lib/bind/irs/gai_strerror.c | 4 +++- lib/bind/irs/irs_data.c | 6 ++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index dd8e95c2bc5..2cb620ebc33 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +2140. [bug] libbind: missing unlock on pthread_key_create() + failures. [RT #16654] + 2139. [bug] dns_view_find() was being called with wrong type in adb.c. [RT #16670] diff --git a/lib/bind/irs/gai_strerror.c b/lib/bind/irs/gai_strerror.c index 29196a0a157..90e90cdd154 100644 --- a/lib/bind/irs/gai_strerror.c +++ b/lib/bind/irs/gai_strerror.c @@ -68,8 +68,10 @@ gai_strerror(int ecode) { if (pthread_mutex_lock(&lock) != 0) goto unknown; if (!once) { - if (pthread_key_create(&key, free) != 0) + if (pthread_key_create(&key, free) != 0) { + pthread_mutex_unlock(&lock); goto unknown; + } once = 1; } if (pthread_mutex_unlock(&lock) != 0) diff --git a/lib/bind/irs/irs_data.c b/lib/bind/irs/irs_data.c index ca18394527a..a3e776a60e7 100644 --- a/lib/bind/irs/irs_data.c +++ b/lib/bind/irs/irs_data.c @@ -16,7 +16,7 @@ */ #if !defined(LINT) && !defined(CODECENTER) -static const char rcsid[] = "$Id: irs_data.c,v 1.10 2006/03/09 23:57:56 marka Exp $"; +static const char rcsid[] = "$Id: irs_data.c,v 1.11 2007/02/25 23:46:58 marka Exp $"; #endif #include "port_before.h" @@ -132,8 +132,10 @@ net_data_init(const char *conf_file) { if (pthread_mutex_lock(&keylock) != 0) return (NULL); if (!once) { - if (pthread_key_create(&key, net_data_destroy) != 0) + if (pthread_key_create(&key, net_data_destroy) != 0) { + pthread_mutex_unlock(&keylock); return (NULL); + } once = 1; } if (pthread_mutex_unlock(&keylock) != 0) -- 2.47.3