From 9fbf3b5bed2af5009ddedd9d1bcaa9be58307ad0 Mon Sep 17 00:00:00 2001
From: Andrew Tridgell <andrew@tridgell.net>
Date: Mon, 13 May 2024 20:55:55 +1000
Subject: [PATCH] AP_Scripting: fixed float register save/restore in
 setjmp/longjmp

the register save must happen before the setjmp() call, which means
outside of the LUAI_TRY() macro. We also should be saving all 32
floating point registers
---
 libraries/AP_Scripting/lua/src/ldo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libraries/AP_Scripting/lua/src/ldo.c b/libraries/AP_Scripting/lua/src/ldo.c
index 88b9d921dd..2216cc5a33 100644
--- a/libraries/AP_Scripting/lua/src/ldo.c
+++ b/libraries/AP_Scripting/lua/src/ldo.c
@@ -142,10 +142,10 @@ int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
   lj.status = LUA_OK;
   lj.previous = L->errorJmp;  /* chain new error handler */
   L->errorJmp = &lj;
-  LUAI_TRY(L, &lj,
 #ifdef ARM_MATH_CM7
     __asm__("vpush {s16-s31}");
 #endif
+  LUAI_TRY(L, &lj,
     (*f)(L, ud);
   );
 #ifdef ARM_MATH_CM7