summarylogtreecommitdiffstats
path: root/starship-stack-underflow-guard.patch
blob: f42a4c125be1048a2c5ba9582e9b3ab91de2b7bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/src/port/interpolation/FrameInterpolation.cpp b/src/port/interpolation/FrameInterpolation.cpp
index 8d6c31ce..341adb12 100644
--- a/src/port/interpolation/FrameInterpolation.cpp
+++ b/src/port/interpolation/FrameInterpolation.cpp
@@ -313,6 +313,10 @@ struct InterpolateCtx {
 
                         case Op::MatrixPop:
                             Matrix_Pop(&gInterpolationMatrix);
+                            // Temporary fix to prevent stack underflow eventually causing undefined behavior
+                            if (gInterpolationMatrix - sInterpolationMatrixStack < 0) {
+                                gInterpolationMatrix = &sInterpolationMatrixStack[0];
+                            }
                             break;
 
                      // Unused on SF64