Merge "Handle out-of-bound indices"
This commit is contained in:
commit
06fc4aa74c
1 changed files with 10 additions and 5 deletions
|
@ -70,16 +70,21 @@ ScopedAStatus HdmiConnectionMock::setCallback(
|
|||
}
|
||||
|
||||
ScopedAStatus HdmiConnectionMock::setHpdSignal(HpdSignal signal, int32_t portId) {
|
||||
if (mHdmiThreadRun) {
|
||||
mHpdSignal.at(portId - 1) = signal;
|
||||
return ScopedAStatus::ok();
|
||||
} else {
|
||||
if (portId > mTotalPorts || portId < 1) {
|
||||
return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
||||
}
|
||||
if (!mHdmiThreadRun) {
|
||||
return ScopedAStatus::fromServiceSpecificError(
|
||||
static_cast<int32_t>(Result::FAILURE_INVALID_STATE));
|
||||
}
|
||||
mHpdSignal.at(portId - 1) = signal;
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ScopedAStatus HdmiConnectionMock::getHpdSignal(int32_t portId, HpdSignal* _aidl_return) {
|
||||
if (portId > mTotalPorts || portId < 1) {
|
||||
return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
||||
}
|
||||
*_aidl_return = mHpdSignal.at(portId - 1);
|
||||
return ScopedAStatus::ok();
|
||||
}
|
||||
|
@ -123,7 +128,7 @@ void HdmiConnectionMock::handleHotplugMessage(unsigned char* msgBuf) {
|
|||
bool connected = ((msgBuf[3]) & 0xf) > 0;
|
||||
int32_t portId = static_cast<uint32_t>(msgBuf[0] & 0xf);
|
||||
|
||||
if (portId > static_cast<int32_t>(mPortInfos.size())) {
|
||||
if (portId > static_cast<int32_t>(mPortInfos.size()) || portId < 1) {
|
||||
ALOGD("[halimp_aidl] ignore hot plug message, id %x does not exist", portId);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue