Skip to content

Commit d5e9cbc

Browse files
Merge pull request livecode#7553 from livecodeian/bugfix-23168
[[ Bug 23168 ]] Fix memory leak when rendering "good" quality gradients
2 parents 8627bf8 + e443df1 commit d5e9cbc

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

docs/notes/bugfix-23168.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix memory leak when rendering gradients where the quality is set to "good"

libgraphics/src/legacygradients.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,12 +315,13 @@ class MCGGeneralizedGradientShader : public SkShader
315315
m_buffer = nullptr;
316316
m_buffer_width = 0;
317317
}
318-
319-
~Context()
320-
{
321-
MCMemoryDeleteArray(m_ramp);
322-
}
323-
318+
319+
~Context()
320+
{
321+
MCMemoryDeleteArray(m_buffer);
322+
MCMemoryDeleteArray(m_ramp);
323+
}
324+
324325
virtual void shadeSpan(int x, int y, SkPMColor dstC[], int count) override
325326
{
326327
if (m_combine == nullptr)
@@ -339,7 +340,7 @@ class MCGGeneralizedGradientShader : public SkShader
339340
{
340341
if ((int)m_buffer_width < count * GRADIENT_AA_SCALE)
341342
{
342-
uindex_t t_size = m_buffer_width * GRADIENT_AA_SCALE * GRADIENT_AA_SCALE;
343+
uindex_t t_size = m_buffer_width * GRADIENT_AA_SCALE;
343344
if (!MCMemoryResizeArray(count * GRADIENT_AA_SCALE * GRADIENT_AA_SCALE, m_buffer, t_size))
344345
{
345346
return;

0 commit comments

Comments
 (0)