Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a57e4637 authored by Stephen Hines's avatar Stephen Hines
Browse files

Fix an invalid memory access detected by ASan stack-use-after-return.

The latest ASan from our compiler update (http://b/241011085) enables
the stack-use-after-return check by default. This caught an issue in a
Bluetooth test, where the test was initialized with an empty set of
presets that are accidentally then iterated over starting with a direct
access of the first nonexistent entry (lines 271-276 of
has_client_test.cc). This fix switches the tests to use the default
nullopt instead of an empty set, which then allows for a default set to
be created before access.

Bug: http://b/241963581
Test: atest --host bluetooth_has_test64
Change-Id: If500815340051f53890e4d751d9ad528bc1be2a2
parent 3b083f8d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1343,7 +1343,7 @@ TEST_F(HasClientTest, test_reconnect_after_encryption_failed_from_storage) {

TEST_F(HasClientTest, test_load_from_storage_and_connect) {
  const RawAddress test_address = GetTestAddress(1);
  SetSampleDatabaseHasPresetsNtf(test_address, kFeatureBitDynamicPresets, {{}});
  SetSampleDatabaseHasPresetsNtf(test_address, kFeatureBitDynamicPresets);
  SetEncryptionResult(test_address, true);

  std::set<HasPreset, HasPreset::ComparatorDesc> has_presets = {{
@@ -1413,7 +1413,7 @@ TEST_F(HasClientTest, test_load_from_storage_and_connect) {

TEST_F(HasClientTest, test_load_from_storage) {
  const RawAddress test_address = GetTestAddress(1);
  SetSampleDatabaseHasPresetsNtf(test_address, kFeatureBitDynamicPresets, {{}});
  SetSampleDatabaseHasPresetsNtf(test_address, kFeatureBitDynamicPresets);
  SetEncryptionResult(test_address, true);

  std::set<HasPreset, HasPreset::ComparatorDesc> has_presets = {{