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

Array out of bounds bug in calculate_slopes() and in pt_in_polygon() #7

Open
luisvega-lm opened this issue May 16, 2024 · 0 comments
Open
Assignees

Comments

@luisvega-lm
Copy link

In calculate_slopes() and pt_in_polygon(), num_saa is the number of points in the SAA polygon. This should correspond to the size of the arrays lat and lon ... meaning that the last valid index of the arrays is (num_saa -1).

In both functions, when the num_saa is used in the for-loop, the last value of i = (num_saa -1). The problem is that the implementation includes the use of lat[i+1] and lon[i+1]. This means that the logic is going out of bounds from the valid memory limits of the array.

The reason why this error is not crashing at runtime is because the two arrays being passed to the functions (from saa() )are of size 52 while the valid data is only 13 entries. (i.e., the array buffer is bigger than num_saa).

Base on the logic in this algorithm the following values will always be invalid:

  • slopes[0] and intercepts[0] ... this values are never set
  • slopes[num_ssa -1] and intercepts[num_ssa -1] ... values are based on invalid/unknown values from out-of-bounds lat[num_saa] and lon[num_saa]
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

2 participants