Skip to content

Commit 316cb2a

Browse files
committed
pkey: do not check NULL argument in ossl_pkey_new()
Passing NULL to ossl_pkey_new() makes no sense in the first place, and in fact it is ensured not to be NULL in all cases.
1 parent 8193b73 commit 316cb2a

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

ext/openssl/ossl_pkey.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,8 @@ pkey_new0(VALUE arg)
3939
{
4040
EVP_PKEY *pkey = (EVP_PKEY *)arg;
4141
VALUE klass, obj;
42-
int type;
4342

44-
if (!pkey || (type = EVP_PKEY_base_id(pkey)) == EVP_PKEY_NONE)
45-
ossl_raise(rb_eRuntimeError, "pkey is empty");
46-
47-
switch (type) {
43+
switch (EVP_PKEY_base_id(pkey)) {
4844
#if !defined(OPENSSL_NO_RSA)
4945
case EVP_PKEY_RSA: klass = cRSA; break;
5046
#endif

ext/openssl/ossl_pkey.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ extern const rb_data_type_t ossl_evp_pkey_type;
3535
} \
3636
} while (0)
3737

38+
/* Takes ownership of the EVP_PKEY */
3839
VALUE ossl_pkey_new(EVP_PKEY *);
3940
void ossl_pkey_check_public_key(const EVP_PKEY *);
4041
EVP_PKEY *ossl_pkey_read_generic(BIO *, VALUE);

0 commit comments

Comments
 (0)