diff --git a/services/ui/driver/graphic_engine.cpp b/services/ui/driver/graphic_engine.cpp index a0f881acb34777dd3be523074248829e945a0ccf..c318b5bff7fb91b3dd104f576d21622bd1478ef5 100644 --- a/services/ui/driver/graphic_engine.cpp +++ b/services/ui/driver/graphic_engine.cpp @@ -119,7 +119,11 @@ void GraphicEngine::FlushThreadLoop() const if (stopClear_) { 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)); } }