diff --git a/frameworks/common/screen.cpp b/frameworks/common/screen.cpp index ac9e1ce7fc66225e92ec1c646f41cc9d17a80747..b0e344a4c50f26cf738238c7b069d3068c7f30fb 100755 --- a/frameworks/common/screen.cpp +++ b/frameworks/common/screen.cpp @@ -43,6 +43,7 @@ bool Screen::GetCurrentScreenBitmap(ImageInfo& info) info.header.compressMode = 0; if (!ScreenDeviceProxy::GetInstance()->GetScreenBitmapBuffer(screenBitmapBuffer, info.dataSize)) { + ImageCacheFree(info); return false; } info.data = screenBitmapBuffer; diff --git a/frameworks/components/ui_view.cpp b/frameworks/components/ui_view.cpp index fb60753f991f80f9ef1b51bb2fb2fd219f235de5..beeeaf8790a0f7f47ca93bed1398ae035d68d3b8 100755 --- a/frameworks/components/ui_view.cpp +++ b/frameworks/components/ui_view.cpp @@ -22,6 +22,7 @@ #include "draw/draw_utils.h" #include "gfx_utils/graphic_log.h" #include "gfx_utils/mem_api.h" +#include "securec.h" #include "themes/theme_manager.h" namespace OHOS { @@ -829,8 +830,8 @@ bool UIView::GetBitmap(ImageInfo& bitmap) rect_.SetPosition(0, 0); Rect mask = GetRect(); mask.Intersect(mask, screenRect); - uint16_t bufferWidth = mask.GetWidth(); - uint16_t bufferHeight = mask.GetHeight(); + uint16_t bufferWidth = static_cast(mask.GetWidth()); + uint16_t bufferHeight = static_cast(mask.GetHeight()); bitmap.header.colorMode = ScreenDeviceProxy::GetInstance()->GetBufferMode(); bitmap.dataSize = bufferWidth * bufferHeight * DrawUtils::GetByteSizeByColorMode(bitmap.header.colorMode); bitmap.header.width = bufferWidth; @@ -844,6 +845,10 @@ bool UIView::GetBitmap(ImageInfo& bitmap) rect_.SetPosition(tempX, tempY); return false; } + if (memset_s(viewBitmapBuffer, bitmap.dataSize, 0, bitmap.dataSize) != EOK) { + ImageCacheFree(bitmap); + return false; + } ScreenDeviceProxy::GetInstance()->EnableBitmapBuffer(viewBitmapBuffer); ScreenDeviceProxy::GetInstance()->SetViewBitmapBufferWidth(bufferWidth); RootView::GetInstance()->DrawTop(this, mask); diff --git a/frameworks/dock/screen_device_proxy.cpp b/frameworks/dock/screen_device_proxy.cpp index 72a4b7b92b34b21d9a8f71244b6ccd0077de0e6e..12d16ca99770c52f4dbacb16f5c2b3a2303a1b75 100755 --- a/frameworks/dock/screen_device_proxy.cpp +++ b/frameworks/dock/screen_device_proxy.cpp @@ -129,6 +129,9 @@ bool ScreenDeviceProxy::GetScreenBitmapBuffer(uint8_t* dest, uint32_t size) return false; } uint8_t* buf = GetBuffer(); + if (buf == nullptr) { + return false; + } if (memcpy_s(dest, size, buf, bufSize) != EOK) { return false; }