From a0568cd61ed688700973b4b8a09d78a8a99eebe5 Mon Sep 17 00:00:00 2001 From: swx1094762 Date: Fri, 10 Mar 2023 11:31:15 +0800 Subject: [PATCH] Description:DrawUtils:: Memory leak in DrawTransform issuesno:I6LNFB Sig:SIG_ApplicationFramework Feature or Bugfix:Feature Binary Source:NO Signed-off-by: swx1094762 --- frameworks/draw/draw_utils.cpp | 7 +++---- frameworks/draw/draw_utils.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/frameworks/draw/draw_utils.cpp b/frameworks/draw/draw_utils.cpp index bc3015d..f33c5ae 100644 --- a/frameworks/draw/draw_utils.cpp +++ b/frameworks/draw/draw_utils.cpp @@ -1880,7 +1880,7 @@ BottomHalf: DrawTriangleTransformPart(gfxDstBuffer, part); } -void DrawUtils::AddBorderToImageData(TransformDataInfo& newDataInfo) +void DrawUtils::AddBorderToImageData(TransformDataInfo& newDataInfo, ImageInfo& imageinfo) { int16_t border = 1; // 1 : border width int16_t offset = border * 2; // 2 : offset @@ -1900,7 +1900,6 @@ void DrawUtils::AddBorderToImageData(TransformDataInfo& newDataInfo) if ((width * newDataInfo.pxSize) % FONT_WEIGHT_8 != 0) { widthInByte++; } - ImageInfo imageinfo; imageinfo.header.width = newDataInfo.header.width; imageinfo.header.height = newDataInfo.header.height; imageinfo.dataSize = widthInByte * height; @@ -1983,6 +1982,7 @@ void DrawUtils::DrawTransform(BufferInfo& gfxDstBuffer, if ((gfxDstBuffer.virAddr == nullptr) || (dataInfo.data == nullptr)) { return; } + ImageInfo imageinfo; TransformDataInfo newDataInfo = dataInfo; TransformMap newTransMap = transMap; // If the width and height of the rectangle of transMap are not equal to the width and height of the ImageHeader, @@ -1990,7 +1990,7 @@ void DrawUtils::DrawTransform(BufferInfo& gfxDstBuffer, if ((transMap.GetTransMapRect().GetWidth() == dataInfo.header.width) && (transMap.GetTransMapRect().GetHeight() == dataInfo.header.height)) { // Add a border of transparency values to the data - AddBorderToImageData(newDataInfo); + AddBorderToImageData(newDataInfo, imageinfo); // Update the transMap according to new rect width and height UpdateTransMap(newDataInfo.header.width, newDataInfo.header.height, newTransMap); } @@ -1998,7 +1998,6 @@ void DrawUtils::DrawTransform(BufferInfo& gfxDstBuffer, Rect trans = newTransMap.GetBoxRect(); trans.SetX(trans.GetX() + position.x); trans.SetY(trans.GetY() + position.y); - ImageInfo imageinfo; imageinfo.data = newDataInfo.data; if (!trans.Intersect(trans, mask)) { if (newDataInfo.data != dataInfo.data) { diff --git a/frameworks/draw/draw_utils.h b/frameworks/draw/draw_utils.h index cf144e8..aca06e1 100644 --- a/frameworks/draw/draw_utils.h +++ b/frameworks/draw/draw_utils.h @@ -355,7 +355,7 @@ private: static OpacityType GetPxAlphaForAlphaImg(const TransformDataInfo& dataInfo, const Point& point); - static void AddBorderToImageData(TransformDataInfo& newDataInfo); + static void AddBorderToImageData(TransformDataInfo& newDataInfo, ImageInfo& imageinfo); static void UpdateTransMap(int16_t width, int16_t height, TransformMap& transMap); -- GitLab