Closed abetusk closed 4 months ago
Thank you. I'm just wondering: how can one get so many iterations? Unless this was called in a loop, the recursion depth should never be this large (it should be a logarithm).
Getting individual values is logarithmic and calling the function a few times doesn't trigger the issue.
The C program version (compiled with the GILBERT_MAIN
define set) loops over every element, either (x,y)
pairs or the index, so any dimensions that exceed the hard coded value will trigger this issue. In this case, max_iter
was set to 100,000
, and 460 * 460 = 211600 > 100000
.
The problem was actually much much worse, in that the max_iter
variable is static to the function, so it's not just that it gets incremented if the function gets called in order, it gets incremented if the function gets called at all, so calling the function gilbert_d2xy_r(&x, &y, 0, 10, 10)
over 100,000 times would have also triggered the issue.
gilbert_d2xy(&x, &y, 7861, 490, 490)
to incorrectly return -1 (there was amax_iter
check to return after some hard coded value)gilbert.c
had buffer overrun setting last byte ofbuf
, correctly setsbuf[1023]='\0'
instead ofbuf[1024]