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

NaN coordinates cause segfault #44

Open
sfreilich opened this issue May 18, 2023 · 0 comments
Open

NaN coordinates cause segfault #44

sfreilich opened this issue May 18, 2023 · 0 comments

Comments

@sfreilich
Copy link

sfreilich commented May 18, 2023

If the input coordinates are NaN, the call to tessTesselate segfaults in pqInit, since the code falsely assumes a total ordering. Possibly tessAddCountour should check that the values are not NaN?

Specifically, it defines its comparisons as:

#define LT(x,y)     (! LEQ(y,x))
#define GT(x,y)     (! LEQ(x,y))

The function LEQ eventually expands to does comparisons with <= and <, which are always false for NaN. Thus LT(x, y) is always true, and the code here:

do {
  do { ++i; } while( GT( **i, *piv ));
  do { --j; } while( LT( **j, *piv ));
  Swap( i, j );
} while( i < j );

increments i until that pointer escapes the array bounds.

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

1 participant