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

Segmentation fault where no data #44

Open
paulharris opened this issue Apr 16, 2012 · 0 comments
Open

Segmentation fault where no data #44

paulharris opened this issue Apr 16, 2012 · 0 comments

Comments

@paulharris
Copy link

If you create a KDTreeSingleIndex with no data, it will segfault when you call buildIndex().

This assumes that you create the dataset matrix with the number of columns that it would have IF there were data,
but with zero rows.

Minimal example:

// empty dataset, with 3 columns if there were data.
Matrix dataset(NULL, 0, 3);
KDTreeSingleIndex< L2 > index(dataset);
index.buildIndex();

This also happens for findNeighbors() due to computeInitialDistances() segfault.

I would suggest either assert()ing that there is data, or doing an if (empty) return; or similar.

thanks again,
Paul

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