nanosvg icon indicating copy to clipboard operation
nanosvg copied to clipboard

Bug: "else" missing

Open jstimpfle opened this issue 2 years ago • 3 comments

In nanosvgrast.h, line 1285:

	if (grad->nstops == 0) {
		for (i = 0; i < 256; i++)
			cache->colors[i] = 0;
	} if (grad->nstops == 1) {
		for (i = 0; i < 256; i++)
			cache->colors[i] = nsvg__applyOpacity(grad->stops[i].color, opacity);
	} else {

Pretty sure an "else" is missing in front of the 2nd "if"

jstimpfle avatar Mar 01 '23 08:03 jstimpfle

You are IMHO right. And that would mean it will go into the 'else' case when grad->nstops = 0 and will do nonsense there or segfault as it loops with for (i = 0; i < grad->nstops-1; i++). @memononen ?

wcout avatar Nov 22 '23 04:11 wcout

Looks reasonable ! Could you prepare a pull request? This makes it easy for memonen to just push one button. The message is nearly 6 months old? Ok, I was not aware of it.

Take care, Harald

oehhar avatar Nov 22 '23 18:11 oehhar

This issue should be closed now that a fix is merged. Also commits that reference issues are trouble, PR comments that say "Fixes #NNN" are good because GH actually acts on them automatically, but commits are trouble because they show up in forks and rebases and such and keep pinging issues & people long after they are relevant. Just tips for future usage...

alerque avatar Nov 22 '23 21:11 alerque