jtsiomb / kdtree

A simple C library for working with KD-Trees
http://nuclear.mutantstargoat.com/sw/kdtree/
Other
391 stars 115 forks source link

float versions send buf instead of bptr (pointer to buffer) #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. use ndim < 16 and float version: insertf, nearestf, nearest_rangef
2.
3.

What is the expected output? What do you see instead?

It segfaults

What version of the product are you using? On what operating system?

svn trunk (rev 29)

Please provide any additional information below.

Attached a patch to fix. There's already two patches but they only fix two of 
the three problem areas. The problem is that, when the dimension is less than 
16 the code does not allocate a new buffer to store the double'd copy of the 
point. Instead, it uses a statically allocated buffer. However, when the double 
version of the same function is called, the pointer that is passed is "buf" 
which is the pointer to the allocated buffer. Instead it should be "bptr" which 
is a pointer to either "buf" or "sbuf" depending on whether or not a new buffer 
was allocated (in the case that dim > 16).

Original issue reported on code.google.com by cheshire...@gmail.com on 6 Apr 2011 at 1:42

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Oops, attached fix had a bug. It should not be "bptr" which is passed, though 
when bptr is set "= sbuf" so should buf. I.e.

bptr = buf = sbuf

instead of 

bptr = sbuf

Attached a new diff.

Original comment by cheshire...@gmail.com on 6 Apr 2011 at 3:30

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks for reporting, commited a fix.

Original comment by jtsi...@gmail.com on 25 Nov 2011 at 12:06