From 3b85a4e59ad649211ddb5be4ec25addf289195a0 Mon Sep 17 00:00:00 2001 From: Ping Fan Date: Thu, 20 Jun 2024 20:15:36 +0800 Subject: [PATCH] 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 --- .../aidl/vts/functional/VtsHalTvInputTargetTest.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp index 7e095f1499..41a78ebeb4 100644 --- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp +++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp @@ -137,13 +137,15 @@ int32_t TvInputAidlTest::getNumNotIn(vector& 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;