diff --git a/src/rs.cpp b/src/rs.cpp index 22c6556512..970c3e632d 100644 --- a/src/rs.cpp +++ b/src/rs.cpp @@ -4170,9 +4170,9 @@ bool is_pixel_in_line(const float curr[2], const float start[2], const float end void adjust_2D_point_to_boundary(float p[2], int width, int height) { if (p[0] < 0) p[0] = 0; - if (p[0] > width) p[0] = (float)width; + if (p[0] >= width) p[0] = (float)width - 1; if (p[1] < 0) p[1] = 0; - if (p[1] > height) p[1] = (float)height; + if (p[1] >= height) p[1] = (float)height - 1; }