From 93e4be5a0bf633c44c6a7fbb9f4ec6d6aeacfa76 Mon Sep 17 00:00:00 2001 From: chenxiaobaobb <2664761650@qq.com> Date: Fri, 20 Dec 2024 03:08:51 +0000 Subject: [PATCH] =?UTF-8?q?update=20plugins/extend=5Fconstraints/src/motio?= =?UTF-8?q?n=5Fsensor=5Fmonitor.cpp.=20=EF=BC=88cherry=20picked=20commit?= =?UTF-8?q?=20from=20=20Signe?= =?UTF-8?q?d-off-by:=20chenxiaobaobb=20<2664761650@qq.com>?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/extend_constraints/src/motion_sensor_monitor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/extend_constraints/src/motion_sensor_monitor.cpp b/plugins/extend_constraints/src/motion_sensor_monitor.cpp index 7c78dae..8c241e5 100644 --- a/plugins/extend_constraints/src/motion_sensor_monitor.cpp +++ b/plugins/extend_constraints/src/motion_sensor_monitor.cpp @@ -27,6 +27,7 @@ namespace OHOS { namespace DevStandbyMgr { namespace { const int32_t COUNT_TIMES = 15; + const int32_t MAX_COUNT_SENSOR = 200; } double MotionSensorMonitor::energy_ = 0; @@ -45,6 +46,10 @@ MotionSensorMonitor::MotionSensorMonitor(int32_t detectionTimeOut, int32_t restT bool MotionSensorMonitor::CheckSersorUsable(SensorInfo *sensorInfo, int32_t count, int32_t sensorTypeId) { + if (sensorInfo == nullptr || !(count > 0 && count < MAX_COUNT_SENSOR)) { + STANDBYSERVICE_LOGE("standby service sensor info is invalid"); + return false; + } SensorInfo *pt = sensorInfo + count; for (SensorInfo *ps = sensorInfo; ps < pt; ++ps) { if (sensorInfo->sensorTypeId == sensorTypeId) { -- Gitee