Commit 4cffcbaf4a2 for php.net
commit 4cffcbaf4a2cc7fec6838061cd3cd916f20d26c4
Author: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Date: Wed Jan 28 18:27:43 2026 +0100
Add missing error check on BN_CTX_new()
If this fails, then the big numbers will be allocated outside of the
context, leading to leaks.
Closes GH-21061.
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c
index b10bd561ff5..1fa4597393d 100644
--- a/ext/openssl/openssl.c
+++ b/ext/openssl/openssl.c
@@ -4423,6 +4423,9 @@ static bool php_openssl_pkey_init_legacy_ec(EC_KEY *eckey, zval *data, bool *is_
EC_POINT *point_q = NULL;
EC_GROUP *group = NULL;
BN_CTX *bctx = BN_CTX_new();
+ if (!bctx) {
+ goto clean_exit;
+ }
*is_private = false;