During initialization, the loop that does the reads can go out of bounds. The return value is -1 but there is no check for that. Thus the loop keeps going for much longer than it has to.
While we are here, also sanitize the usage of the contourindex variable as some of that looks suspicious.
During initialization, the loop that does the reads can go out of bounds. The return value is -1 but there is no check for that. Thus the loop keeps going for much longer than it has to.
While we are here, also sanitize the usage of the contourindex variable as some of that looks suspicious.