]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - crypto/dh/dh_lib.c
fix memory allocation and reference counting issues
[thirdparty/openssl.git] / crypto / dh / dh_lib.c
index f774c043835f13950b2a19b73dcaed73d1ee0a71..d67511f15c4e46d6914d5270d00b2ceba418434c 100644 (file)
@@ -85,8 +85,11 @@ static DH *dh_new_intern(ENGINE *engine, OSSL_LIB_CTX *libctx)
         return NULL;
     }
 
-    if (!CRYPTO_NEW_REF(&ret->references, 1))
-        goto err;
+    if (!CRYPTO_NEW_REF(&ret->references, 1)) {
+        CRYPTO_THREAD_lock_free(ret->lock);
+        OPENSSL_free(ret);
+        return NULL;
+    }
 
     ret->libctx = libctx;
     ret->meth = DH_get_default_method();