From e9f2a376e3baf071eb86c5ac4882aafbe038f47d Mon Sep 17 00:00:00 2001 From: Alan Casalboni Date: Wed, 5 Jun 2024 15:18:20 +0200 Subject: [PATCH] align to width and height -1 to prevent SSEGV accessing out of range index on frame buffer --- src/rs.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rs.cpp b/src/rs.cpp index 281922ca8f..a51db15ec5 100644 --- a/src/rs.cpp +++ b/src/rs.cpp @@ -4145,9 +4145,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; }