From ca9e250ad38058ec194302719896ca656d23510e Mon Sep 17 00:00:00 2001 From: Torben Ewert Date: Sat, 28 Sep 2024 15:40:00 +0200 Subject: [PATCH] fix: check bounds of original image height --- lib/OSnap_Diff/OSnap_Diff.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/OSnap_Diff/OSnap_Diff.ml b/lib/OSnap_Diff/OSnap_Diff.ml index b1cc288..516e811 100644 --- a/lib/OSnap_Diff/OSnap_Diff.ml +++ b/lib/OSnap_Diff/OSnap_Diff.ml @@ -88,7 +88,8 @@ let diff in if not (Int32.equal diff_pixel 0x00000000l) then diff_pixel - else ( + else if row < original_image.height + then ( let pixel = Array1.get original_image.image @@ -105,7 +106,8 @@ let diff let b = (mono land 0xFF) lsl 16 in let g = (mono land 0xFF) lsl 8 in let r = (mono land 0xFF) lsl 0 in - Int32.of_int (a lor b lor g lor r))) + Int32.of_int (a lor b lor g lor r)) + else 0x00000000l) else if col > new_image_start && col <= new_image_end && row < new_image.height then Array1.get new_image.image ((row * new_image.width) + (col - new_image_start)) else 0x00000000l