sw_engine: fix too small memory alloc for spans

In some clipping cases, the memory allocated for storing spans
was too small. As a result, the entire clipped area might not
have been rendered.
This has been resolved by adding an experimental factor to increase
the size of allocated memory.

@issue: https://github.com/thorvg/thorvg/issues/3461
This commit is contained in:
Mira Grudzinska 2025-05-21 11:09:46 +02:00 committed by Hermet Park
parent 1d0973cdf0
commit 1b72113fcc

View file

@ -997,7 +997,7 @@ void rleFree(SwRle* rle)
bool rleClip(SwRle *rle, const SwRle *clip)
{
if (rle->size == 0 || clip->size == 0) return false;
auto spanCnt = rle->size > clip->size ? rle->size : clip->size;
auto spanCnt = 2 * (rle->size > clip->size ? rle->size : clip->size); //factor 2 added for safety (no real cases observed where the factor exceeded 1.4)
auto spans = tvg::malloc<SwSpan*>(sizeof(SwSpan) * (spanCnt));
auto spansEnd = _intersectSpansRegion(clip, rle, spans, spanCnt);