From 55d9ced3cf9d0d9dce6474ad4a9d88c52ff052d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Tue, 10 Dec 2024 14:00:02 +0900 Subject: [PATCH] image: fix slice in image view --- src/image.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/image.zig b/src/image.zig index a281cd7..bf730e2 100644 --- a/src/image.zig +++ b/src/image.zig @@ -83,7 +83,7 @@ pub fn Image(comptime T: type) type { return .{ .rows = rect.height(), .cols = rect.width(), - .data = self.data[rect.t * self.stride + rect.l .. rect.b * self.stride + rect.b], + .data = self.data[rect.t * self.stride + rect.l .. rect.b * self.stride + rect.r + 1], .stride = self.cols, }; } @@ -297,6 +297,7 @@ pub fn Image(comptime T: type) type { const r2_offset = r2 * self.cols; const r2_r1 = r2 - r1; if (r1 >= radius and r2 <= self.rows - 1 - radius and + self.cols >= 1 + radius + simd_len and c >= radius and c <= self.cols - 1 - radius - simd_len and rem >= simd_len) {