diff --git a/services/ui/driver/graphic_engine.cpp b/services/ui/driver/graphic_engine.cpp index 58fa48b52b77ac9ee8ed7f0588018ee7e31a3a0a..bfc59a11ce334d8a3c34abfa0ff9716c0b0add82 100644 --- a/services/ui/driver/graphic_engine.cpp +++ b/services/ui/driver/graphic_engine.cpp @@ -112,7 +112,11 @@ void GraphicEngine::FlushThreadLoop() const // clear screen after stop UiRotation::GetInstance().SetDegree(UI_ROTATION_DEGREE::UI_ROTATION_0); uint8_t pixelBytes = OHOS::DrawUtils::GetByteSizeByColorMode(colorMode_); - (void)memset_s(buffInfo_->virAddr, width_ * height_ * pixelBytes, 0, width_ * height_ * pixelBytes); + uint32_t picSize = 0; + if (__builtin_mul_overflow(width_ * height_, pixelBytes, &picSize)) { + return; + } + (void)memset_s(buffInfo_->virAddr, picSize, 0, picSize); sfDev_->Flip(reinterpret_cast(buffInfo_->virAddr)); }