Skip to content

Commit

Permalink
Don't leak memory
Browse files Browse the repository at this point in the history
  • Loading branch information
justsmth committed Jan 15, 2025
1 parent 74910e3 commit 3924c67
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crypto/evp_extra/p_pqdsa_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1378,19 +1378,22 @@ TEST_P(PQDSAParameterTest, MarshalParse) {
bssl::UniquePtr<EVP_PKEY> pub_pkey_from_der(EVP_parse_public_key(&cbs));
ASSERT_TRUE(pub_pkey_from_der.get());
EXPECT_EQ(1, EVP_PKEY_cmp(pkey.get(), pub_pkey_from_der.get()));
free_der.release();

// ---- 3. Test encode (marshal) and decode (parse) of private key ----
// The private key must encode properly.
ASSERT_TRUE(CBB_init(cbb.get(), 0));
ASSERT_TRUE(EVP_marshal_private_key(cbb.get(), pkey.get()));
ASSERT_TRUE(CBB_finish(cbb.get(), &der, &der_len));
free_der.reset(der);

// The private key must parse properly.
CBS_init(&cbs, der, der_len);
bssl::UniquePtr<EVP_PKEY> priv_pkey_from_der(EVP_parse_private_key(&cbs));
ASSERT_TRUE(priv_pkey_from_der);
EXPECT_EQ(Bytes(priv_pkey_from_der->pkey.pqdsa_key->private_key, GetParam().private_key_len),
Bytes(pkey->pkey.pqdsa_key->private_key, GetParam().private_key_len));
free_der.release();
}

TEST_P(PQDSAParameterTest, SIGOperations) {
Expand Down

2 comments on commit 3924c67

@jakemas
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used in a few more spots

@justsmth
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the "reset" is technically correct, but a little confusing for static analysis (and apparently for me as well). I'll update these other places.

Please sign in to comment.