Skip to content

Commit

Permalink
fix asan memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
rockspore committed Oct 21, 2023
1 parent 948fd6b commit 53d7a5b
Showing 1 changed file with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,23 @@ alts_zero_copy_grpc_protector_test_fixture_create(bool rekey,
static_cast<alts_zero_copy_grpc_protector_test_fixture*>(
gpr_zalloc(sizeof(alts_zero_copy_grpc_protector_test_fixture)));
size_t key_length = rekey ? kAes128GcmRekeyKeyLength : kAes128GcmKeyLength;
uint8_t* key;
size_t max_protected_frame_size = 1024;
size_t actual_max_protected_frame_size;
gsec_test_random_array(&key, key_length);
EXPECT_EQ(
alts_zero_copy_grpc_protector_create(
key, key_length, copy_key, rekey, /*is_client=*/true, integrity_only,
enable_extra_copy, &max_protected_frame_size, &fixture->client),
TSI_OK);
gsec_test_random_array(&fixture->key, key_length);
EXPECT_EQ(alts_zero_copy_grpc_protector_create(
fixture->key, key_length, copy_key, rekey, /*is_client=*/true,
integrity_only, enable_extra_copy, &max_protected_frame_size,
&fixture->client),
TSI_OK);
EXPECT_EQ(tsi_zero_copy_grpc_protector_max_frame_size(
fixture->client, &actual_max_protected_frame_size),
TSI_OK);
EXPECT_EQ(actual_max_protected_frame_size, max_protected_frame_size);
EXPECT_EQ(
alts_zero_copy_grpc_protector_create(
key, key_length, copy_key, rekey, /*is_client=*/false, integrity_only,
enable_extra_copy, &max_protected_frame_size, &fixture->server),
TSI_OK);
EXPECT_EQ(alts_zero_copy_grpc_protector_create(
fixture->key, key_length, copy_key, rekey, /*is_client=*/false,
integrity_only, enable_extra_copy, &max_protected_frame_size,
&fixture->server),
TSI_OK);
EXPECT_EQ(tsi_zero_copy_grpc_protector_max_frame_size(
fixture->server, &actual_max_protected_frame_size),
TSI_OK);
Expand Down Expand Up @@ -316,14 +315,14 @@ static void alts_zero_copy_protector_seal_unseal_large_buffer_tests(

TEST(AltsZeroCopyGrpcProtectorTest, MainTest) {
grpc_init();
alts_zero_copy_protector_seal_unseal_small_buffer_tests(
/*enable_extra_copy=*/false, /*copy_key=*/true);
alts_zero_copy_protector_seal_unseal_small_buffer_tests(
/*enable_extra_copy=*/true, /*copy_key=*/true);
alts_zero_copy_protector_seal_unseal_large_buffer_tests(
/*enable_extra_copy=*/false, /*copy_key=*/false);
alts_zero_copy_protector_seal_unseal_large_buffer_tests(
/*enable_extra_copy=*/true, /*copy_key=*/false);
for (bool enable_extra_copy : {false, true}) {
for (bool copy_key : {false, true}) {
alts_zero_copy_protector_seal_unseal_small_buffer_tests(enable_extra_copy,
copy_key);
alts_zero_copy_protector_seal_unseal_large_buffer_tests(enable_extra_copy,
copy_key);
}
}
grpc_shutdown();
}

Expand Down

0 comments on commit 53d7a5b

Please sign in to comment.