diff --git a/goal_src/jak2/levels/city/common/height-map.gc b/goal_src/jak2/levels/city/common/height-map.gc index f600684609..2dfa6089ca 100644 --- a/goal_src/jak2/levels/city/common/height-map.gc +++ b/goal_src/jak2/levels/city/common/height-map.gc @@ -103,7 +103,8 @@ (a1-7 (the-as (pointer int8) - (+ (+ (min a2-0 (+ v1-0 -2)) (* (min a1-1 (+ a3-0 -2)) v1-0) 0) (the-as int (the-as pointer (-> this data)))) + ;; og:preserve-this prevent array out-of-bounds access + (+ (+ (min (max 0 a2-0) (+ v1-0 -2)) (* (min (max 0 a1-1) (+ a3-0 -2)) v1-0) 0) (the-as int (the-as pointer (-> this data)))) ) ) (f3-3 (the float (-> a1-7 0))) diff --git a/goal_src/jak3/levels/city/common/height-map.gc b/goal_src/jak3/levels/city/common/height-map.gc index 0002e25e6b..10926a9b27 100644 --- a/goal_src/jak3/levels/city/common/height-map.gc +++ b/goal_src/jak3/levels/city/common/height-map.gc @@ -95,7 +95,8 @@ (a1-7 (the-as (pointer int8) - (+ (+ (min a2-0 (+ v1-0 -2)) (* (min a1-1 (+ a3-0 -2)) v1-0) 0) (the-as int (the-as pointer (-> this data)))) + ;; og:preserve-this prevent array out-of-bounds access + (+ (+ (min (max 0 a2-0) (+ v1-0 -2)) (* (min (max 0 a1-1) (+ a3-0 -2)) v1-0) 0) (the-as int (the-as pointer (-> this data)))) ) ) (f3-3 (the float (-> a1-7 0)))