Skip to content

Commit c939a67

Browse files
committed
Fix d leak in ecc openssl_pkey_new
1 parent dfe6f0c commit c939a67

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

ext/openssl/openssl.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4370,7 +4370,7 @@ PHP_FUNCTION(openssl_pkey_new)
43704370
EC_KEY *eckey = NULL;
43714371
EC_GROUP *group = NULL;
43724372
EC_POINT *pnt = NULL;
4373-
const BIGNUM *d;
4373+
BIGNUM *d = NULL;
43744374
pkey = EVP_PKEY_new();
43754375
if (pkey) {
43764376
eckey = EC_KEY_new();
@@ -4418,6 +4418,8 @@ PHP_FUNCTION(openssl_pkey_new)
44184418
php_openssl_store_errors();
44194419
goto clean_exit;
44204420
}
4421+
4422+
BN_free(d);
44214423
} else if ((x = zend_hash_str_find(Z_ARRVAL_P(data), "x", sizeof("x") - 1)) != NULL &&
44224424
Z_TYPE_P(x) == IS_STRING &&
44234425
(y = zend_hash_str_find(Z_ARRVAL_P(data), "y", sizeof("y") - 1)) != NULL &&
@@ -4462,6 +4464,9 @@ PHP_FUNCTION(openssl_pkey_new)
44624464
php_openssl_store_errors();
44634465
}
44644466
clean_exit:
4467+
if (d != NULL) {
4468+
BN_free(d);
4469+
}
44654470
if (pnt != NULL) {
44664471
EC_POINT_free(pnt);
44674472
}

0 commit comments

Comments
 (0)