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

Harden against arbitrary inputs #3

Open
bogdanni opened this issue Jun 28, 2018 · 1 comment
Open

Harden against arbitrary inputs #3

bogdanni opened this issue Jun 28, 2018 · 1 comment

Comments

@bogdanni
Copy link
Contributor

The first three normalize() in drawSegment() of polyline.geom may have trouble with arbitrary input.

I had to define

vec2 safe_normalize(vec2 v)
{
    float len = length(v);
    if (len == 0)
        return vec2(0, 1); // arbitrary
    else
        return v / len;
}

In my observation, ATI drivers do the right thing, NVIDIA and Intel drivers return something unreasonable.

The second pair of normalize() are maybe safe (?).

@vicrucann
Copy link
Owner

Interesting observation. It never came to my mind the normalize() may not be safe and the behavior depends on the drivers. Although, I never seem to have a problem with the default implementation on my NVIDIA, I assume your suggestion makes total sense to make it safer.

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

No branches or pull requests

2 participants