diff
--- a/original.c
+++ b/original.c
@@ -38,6 +38,9 @@
 32 			if (!lower) {
 38 		if (mas.last > max) {
 42 			upper = kmemdup(&entry[max + 1],
+			if (max + 1 >= mas.last) {
+				// Handle error: max is out of bounds 
+				return -EINVAL; 
+			}
+			upper = kmemdup(&entry[max + 1],

