Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: "else" missing #240

Open
jstimpfle opened this issue Mar 1, 2023 · 3 comments
Open

Bug: "else" missing #240

jstimpfle opened this issue Mar 1, 2023 · 3 comments

Comments

@jstimpfle
Copy link

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"

@wcout
Copy link
Contributor

wcout commented Nov 22, 2023

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 ?

@oehhar
Copy link
Contributor

oehhar commented Nov 22, 2023

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

wcout added a commit to wcout/nanosvg that referenced this issue Nov 22, 2023
wcout added a commit to wcout/nanosvg that referenced this issue Nov 22, 2023
memononen added a commit that referenced this issue Nov 22, 2023
Fix for #240: Bug: "else" missing
@alerque
Copy link

alerque commented Nov 22, 2023

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants