已合并
UnexcludeOutputDevices and ExcludeOutputDevices add judge nullptr #15303
huang-jianfei201创建于 5月15日
UnexcludeOutputDevices and ExcludeOutputDevices add judge nullptr #15303
已合并
共 1 个文件变更+4-1
| @@ -2019,6 +2019,8 @@ int32_t AudioPolicyServer::ExcludeOutputDevices(int32_t audioDevUsageIn, | |||
| 2019 | AudioDeviceUsage audioDevUsage = static_cast<AudioDeviceUsage>(audioDevUsageIn); | 2019 | AudioDeviceUsage audioDevUsage = static_cast<AudioDeviceUsage>(audioDevUsageIn); |
| 2020 | CHECK_AND_RETURN_RET_LOG(PermissionUtil::VerifySystemPermission(), ERR_PERMISSION_DENIED, | 2020 | CHECK_AND_RETURN_RET_LOG(PermissionUtil::VerifySystemPermission(), ERR_PERMISSION_DENIED, |
| 2021 | "No system permission"); | 2021 | "No system permission"); |
| 2022 | + CHECK_AND_RETURN_RET_LOG(!newAudioDeviceDescriptors.empty() && newAudioDeviceDescriptors[0] != nullptr, | ||
| 2023 | + ERROR, "audioDeviceDescriptors is empty or audioDeviceDescriptors[0] is nullptr"); | ||
| 2022 | return eventEntry_->ExcludeOutputDevices(audioDevUsage, newAudioDeviceDescriptors); | 2024 | return eventEntry_->ExcludeOutputDevices(audioDevUsage, newAudioDeviceDescriptors); |
| 2023 | } | 2025 | } |
| 2024 | 2026 | ||
| @@ -2029,7 +2031,8 @@ int32_t AudioPolicyServer::UnexcludeOutputDevices(int32_t audioDevUsageIn, | |||
| 2029 | AudioDeviceUsage audioDevUsage = static_cast<AudioDeviceUsage>(audioDevUsageIn); | 2031 | AudioDeviceUsage audioDevUsage = static_cast<AudioDeviceUsage>(audioDevUsageIn); |
| 2030 | CHECK_AND_RETURN_RET_LOG(PermissionUtil::VerifySystemPermission(), ERR_PERMISSION_DENIED, | 2032 | CHECK_AND_RETURN_RET_LOG(PermissionUtil::VerifySystemPermission(), ERR_PERMISSION_DENIED, |
| 2031 | "No system permission"); | 2033 | "No system permission"); |
| 2032 | - | 2034 | + CHECK_AND_RETURN_RET_LOG(!newAudioDeviceDescriptors.empty() && newAudioDeviceDescriptors[0] != nullptr, |
| 2035 | + ERROR, "audioDeviceDescriptors is empty or audioDeviceDescriptors[0] is nullptr"); | ||
| 2033 | return eventEntry_->UnexcludeOutputDevices(audioDevUsage, newAudioDeviceDescriptors); | 2036 | return eventEntry_->UnexcludeOutputDevices(audioDevUsage, newAudioDeviceDescriptors); |
| 2034 | } | 2037 | } |
| 2035 | 2038 | ||