From 7d6df9e9150abc8e0d8f88b02159261e37eea167 Mon Sep 17 00:00:00 2001 From: Pauli Date: Fri, 3 Jun 2016 10:52:32 -0400 Subject: [PATCH] Fix threading issue that at best will leak memory The problem is the checking in policy_cache_set, there is a race condition between the null check and obtaining the lock. The fix is in policy_cache_new to detect if the creation has happened already. Reviewed-by: Richard Levitte --- crypto/x509v3/pcy_cache.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crypto/x509v3/pcy_cache.c b/crypto/x509v3/pcy_cache.c index e254142c0f..a9ee30a8d9 100644 --- a/crypto/x509v3/pcy_cache.c +++ b/crypto/x509v3/pcy_cache.c @@ -78,6 +78,9 @@ static int policy_cache_new(X509 *x) CERTIFICATEPOLICIES *ext_cpols = NULL; POLICY_MAPPINGS *ext_pmaps = NULL; int i; + + if (x->policy_cache != NULL) + return 1; cache = OPENSSL_malloc(sizeof(*cache)); if (cache == NULL) return 0; -- 2.34.1