Fix validation logic in TvInputAidlTest

[Description]
Handle validation incorrectly allows empty integer arrays, causing
potential errors.

Bug:348575546

[Test Report]
Test ok

Change-Id: Ie597fecfaa783b050510b11665a03e31ccb8feaf
(cherry picked from commit 3b85a4e59a)
This commit is contained in:
Ping Fan
2024-06-20 20:15:36 +08:00
committed by archer wu
parent 70be0c430b
commit 73b1d1aa5c

View File

@@ -135,13 +135,15 @@ int32_t TvInputAidlTest::getNumNotIn(vector<int32_t>& nums) {
}
bool TvInputAidlTest::isValidHandle(NativeHandle& handle) {
if (handle.fds.empty()) {
if (handle.fds.empty() && handle.ints.empty()) {
return false;
}
for (size_t i = 0; i < handle.fds.size(); i++) {
int fd = handle.fds[i].get();
if (fcntl(fd, F_GETFL) < 0) {
return false;
if (!(handle.fds.empty())) {
for (size_t i = 0; i < handle.fds.size(); i++) {
int fd = handle.fds[i].get();
if (fcntl(fd, F_GETFL) < 0) {
return false;
}
}
}
return true;