diff options
author | Patrick Luby <guibmacdev@gmail.com> | 2024-02-22 10:01:00 -0500 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-04-15 12:36:24 +0200 |
commit | 2de7b1393530195d4fa4f29dae5cf111225eeb62 (patch) | |
tree | 2ff53c0de90e37873e7d0bdec2774e605a90aef7 /vcl | |
parent | ce9d2e06dd49be79e02937c07adc4ed8db5aa0d1 (diff) |
Related: tdf#159529 eliminate possible memory leak
Despite confirming that the release function passed to
SkBitmap.bitmap.installPixels() does get called for every
data array that has been allocated, Apple's Instruments
indicates that the data is leaking. While it is likely a
false positive, it makes leak analysis difficult so leave
the bitmap mutable. That causes SkBitmap.asImage() to make
a copy of the data and the data can be safely deleted here.
Change-Id: Ib28d70bd5f51e6d3be7a7d7c0d5923d71a6e5390
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/163774
Tested-by: Jenkins
Reviewed-by: Patrick Luby <guibomacdev@gmail.com>
(cherry picked from commit 3e2dde97bc15f156837d10bf4456deb81f7f554a)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165187
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/skia/osx/gdiimpl.cxx | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/vcl/skia/osx/gdiimpl.cxx b/vcl/skia/osx/gdiimpl.cxx index c4bd75184242..9b511ad4469b 100644 --- a/vcl/skia/osx/gdiimpl.cxx +++ b/vcl/skia/osx/gdiimpl.cxx @@ -37,12 +37,6 @@ using namespace SkiaHelper; -static void releaseInstalledPixels(void* pAddr, void*) -{ - if (pAddr) - delete[] static_cast<sal_uInt8*>(pAddr); -} - AquaSkiaSalGraphicsImpl::AquaSkiaSalGraphicsImpl(AquaSalGraphics& rParent, AquaSharedAttributes& rShared) : SkiaSalGraphicsImpl(rParent, rShared.mpFrame) @@ -251,6 +245,7 @@ bool AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n if (!context) { SAL_WARN("vcl.skia", "drawNativeControl(): Failed to allocate bitmap context"); + delete[] data; return false; } // Setup context state for drawing (performDrawNativeControl() e.g. fills background in some cases). @@ -287,12 +282,9 @@ bool AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n if (!bitmap.installPixels(SkImageInfo::Make(width, height, mSurface->imageInfo().colorType(), kPremul_SkAlphaType), - data, width * 4, releaseInstalledPixels, nullptr)) + data, width * 4, nullptr, nullptr)) abort(); - // Make bitmap immutable to avoid making a copy in bitmap.asImage() - bitmap.setImmutable(); - preDraw(); SAL_INFO("vcl.skia.trace", "drawnativecontrol(" << this << "): " << rControlRegion << ":" << int(nType) << "/" << int(nPart)); @@ -312,6 +304,15 @@ bool AquaSkiaSalGraphicsImpl::drawNativeControl(ControlType nType, ControlPart n ++pendingOperationsToFlush; // tdf#136369 postDraw(); } + // Related: tdf#159529 eliminate possible memory leak + // Despite confirming that the release function passed to + // SkBitmap.bitmap.installPixels() does get called for every + // data array that has been allocated, Apple's Instruments + // indicates that the data is leaking. While it is likely a + // false positive, it makes leak analysis difficult so leave + // the bitmap mutable. That causes SkBitmap.asImage() to make + // a copy of the data and the data can be safely deleted here. + delete[] data; return bOK; } |