diff --git a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_time_statistician.cpp b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_time_statistician.cpp index 389bffd1443d93cbb65ea6dec183b397f38b209e..2b94317d77b956835c6ead1052503cd1cebc3b2f 100644 --- a/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_time_statistician.cpp +++ b/services/cameraservice/sourceservice/src/distributedcameramgr/dcameradata/feedingsmoother/derived/dcamera_time_statistician.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2024 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 @@ -72,6 +72,10 @@ int64_t DCameraTimeStatistician::CalAverValue(int64_t& value, int64_t& valueSum) if (frameIndex_ == FRAME_HEAD) { return 0; } + if (INT64_MAX - valueSum < value) { + DHLOGD("CalAverValue addition overflow."); + return 0; + } valueSum += value; return valueSum / frameIndex_; }