From 70afa86d8c57d194e370c848540520e7bb034fca Mon Sep 17 00:00:00 2001 From: klapeto Date: Fri, 29 Dec 2023 18:33:09 +0200 Subject: Fixed invalid memory read on single stop gradient See: https://github.com/memononen/nanosvg/pull/252 --- src/nanosvgrast.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/nanosvgrast.h b/src/nanosvgrast.h index 35175ee9..16b707fe 100644 --- a/src/nanosvgrast.h +++ b/src/nanosvgrast.h @@ -1301,8 +1301,9 @@ static void nsvg__initPaint(NSVGcachedPaint* cache, NSVGpaint* paint, float opac for (i = 0; i < 256; i++) cache->colors[i] = 0; } else if (grad->nstops == 1) { + unsigned int color = nsvg__applyOpacity(grad->stops[0].color, opacity); for (i = 0; i < 256; i++) - cache->colors[i] = nsvg__applyOpacity(grad->stops[i].color, opacity); + cache->colors[i] = color; } else { unsigned int ca, cb = 0; float ua, ub, du, u; -- cgit v1.2.3