Skip to content

Commit

Permalink
Fix d leak in ecc openssl_pkey_new
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jun 21, 2019
1 parent dfe6f0c commit c939a67
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ext/openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4370,7 +4370,7 @@ PHP_FUNCTION(openssl_pkey_new)
EC_KEY *eckey = NULL;
EC_GROUP *group = NULL;
EC_POINT *pnt = NULL;
const BIGNUM *d;
BIGNUM *d = NULL;
pkey = EVP_PKEY_new();
if (pkey) {
eckey = EC_KEY_new();
Expand Down Expand Up @@ -4418,6 +4418,8 @@ PHP_FUNCTION(openssl_pkey_new)
php_openssl_store_errors();
goto clean_exit;
}

BN_free(d);
} else if ((x = zend_hash_str_find(Z_ARRVAL_P(data), "x", sizeof("x") - 1)) != NULL &&
Z_TYPE_P(x) == IS_STRING &&
(y = zend_hash_str_find(Z_ARRVAL_P(data), "y", sizeof("y") - 1)) != NULL &&
Expand Down Expand Up @@ -4462,6 +4464,9 @@ PHP_FUNCTION(openssl_pkey_new)
php_openssl_store_errors();
}
clean_exit:
if (d != NULL) {
BN_free(d);
}
if (pnt != NULL) {
EC_POINT_free(pnt);
}
Expand Down

0 comments on commit c939a67

Please sign in to comment.