!251 修改告警,校验上下限,避免数组下标越界

Merge pull request !251 from 李天刚/master
This commit is contained in:
openharmony_ci
2025-02-11 06:37:51 +00:00
committed by Gitee
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024 Huawei Device Co., Ltd.
* Copyright (c) 2021-2025 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -197,14 +197,14 @@ void DistributedInputHandler::StartInputMonitorDeviceThread()
}
while (isCollectingEvents_) {
size_t count = inputHub_->StartCollectInputHandler(mEventBuffer_, inputDeviceBufferSize_);
if (count > 0) {
DHLOGI("Count: %{public}zu", count);
for (size_t iCnt = 0; iCnt < count; iCnt++) {
NotifyHardWare(iCnt);
}
} else {
DHLOGI("count: %{public}zu", count);
if (count == 0 || count > inputDeviceBufferSize_) {
DHLOGE("Collect input device size is invaild.");
continue;
}
for (size_t iCnt = 0; iCnt < count; iCnt++) {
NotifyHardWare(iCnt);
}
}
isCollectingEvents_ = false;
DHLOGI("DistributedInputHandler::StartCollectEventsThread exit!");