Fix crash issue on test case RadioHidlTest_v1_5#startNetworkScan.

Bad safe_union access is raised by calling the GET method of
eutranBands(), because in default ctor of safe_union RadioAccessSpecifier::Bands
hidl_d is assigned with hidl_discriminator::geranBands, which conflicts
with hidl_discriminator::eutranBands, and leads to crash.

Should use the SET method of eutranBands(&) for assignment purpose.

Fix: 275077563
Bug: 271642958
Change-Id: Ie241e8968eb7f9a1297203be2ab4e0a1bf738dea
Signed-off-by: Jia Jia <jia.jia@zte.com.cn>
This commit is contained in:
Chen Baoyu 2023-03-20 14:51:27 +08:00 committed by Jack Yu
parent 2550e7a719
commit a2881ffbd0

View file

@ -565,9 +565,9 @@ TEST_P(RadioHidlTest_v1_5, startNetworkScan) {
serial = GetRandomSerialNumber();
::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band17;
band17.eutranBands() = {::android::hardware::radio::V1_5::EutranBands::BAND_17};
band17.eutranBands({::android::hardware::radio::V1_5::EutranBands::BAND_17});
::android::hardware::radio::V1_5::RadioAccessSpecifier::Bands band20;
band20.eutranBands() = {::android::hardware::radio::V1_5::EutranBands::BAND_20};
band20.eutranBands({::android::hardware::radio::V1_5::EutranBands::BAND_20});
::android::hardware::radio::V1_5::RadioAccessSpecifier specifier17 = {
.radioAccessNetwork = ::android::hardware::radio::V1_5::RadioAccessNetworks::EUTRAN,
.bands = band17,