Skip to content

Commit

Permalink
Add asserts in testing to fix Coverity alert (#1864)
Browse files Browse the repository at this point in the history
### Description of changes: 
Adds two new asserts to a test to prevent dereferencing a NULL ptr. This
was called out by a Coverity alert.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license and the ISC license.
  • Loading branch information
smittals2 authored Sep 19, 2024
1 parent 7090b90 commit 9972ea8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crypto/pem/pem_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ TEST(PEMTest, WriteReadTraditionalPem) {
ASSERT_TRUE(pkey_read);

EC_KEY *pkey_eckey = EVP_PKEY_get0_EC_KEY(pkey.get());
ASSERT_TRUE(pkey_eckey);
const BIGNUM *orig_priv_key = EC_KEY_get0_private_key(ec_key.get());
const BIGNUM *read_priv_key = EC_KEY_get0_private_key(pkey_eckey);
ASSERT_EQ(0, BN_cmp(orig_priv_key, read_priv_key));
Expand All @@ -419,6 +420,7 @@ TEST(PEMTest, WriteReadTraditionalPem) {
ASSERT_TRUE(pkey_read);

RSA *pkey_rsa = EVP_PKEY_get0_RSA(pkey.get());
ASSERT_TRUE(pkey_rsa);
EXPECT_EQ(0, BN_cmp(RSA_get0_d(pkey_rsa), RSA_get0_d(rsa.get())));
EXPECT_EQ(0, BN_cmp(RSA_get0_d(pkey_rsa), RSA_get0_d(rsa.get())));

Expand Down

0 comments on commit 9972ea8

Please sign in to comment.