From 73b1d1aa5cec508e994483f8575f2906691df947 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 (cherry picked from commit 3b85a4e59ad649211ddb5be4ec25addf289195a0) --- .../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 8d3395b8d2..90404f6735 100644 --- a/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp +++ b/tv/input/aidl/vts/functional/VtsHalTvInputTargetTest.cpp @@ -135,13 +135,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;