diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 2a502f20688cc..d965d9f2bb782 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -4680,6 +4680,9 @@ static EVP_PKEY *php_openssl_pkey_init_ec(zval *data, bool *is_private) { } EVP_PKEY_CTX_free(ctx); ctx = EVP_PKEY_CTX_new(param_key, NULL); + if (!ctx) { + goto cleanup; + } } if (EVP_PKEY_check(ctx) || EVP_PKEY_public_check_quick(ctx)) {