diff options
author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-06 10:22:29 +0200 |
---|---|---|
committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-06-06 10:22:29 +0200 |
commit | a50367194b486e0abbe05aaee34b961e202635ba (patch) | |
tree | 8e991e30e7508e45fb8edcb0b78f33b1227acbc4 /src | |
parent | 4670b7deee3eeca20f72d91d9fb7094b51348956 (diff) | |
download | lanes-a50367194b486e0abbe05aaee34b961e202635ba.tar.gz lanes-a50367194b486e0abbe05aaee34b961e202635ba.tar.bz2 lanes-a50367194b486e0abbe05aaee34b961e202635ba.zip |
Fix Lua stack overflow in KeyUD:peek()
Diffstat (limited to 'src')
-rw-r--r-- | src/keeper.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/keeper.cpp b/src/keeper.cpp index e7574ed..d99cc50 100644 --- a/src/keeper.cpp +++ b/src/keeper.cpp | |||
@@ -139,7 +139,9 @@ void KeyUD::peek(KeeperState const K_, int const count_) | |||
139 | // read <count_> value off the fifo | 139 | // read <count_> value off the fifo |
140 | prepareAccess(K_, -1); // K_: fifo | 140 | prepareAccess(K_, -1); // K_: fifo |
141 | int const _at{ lua_gettop(K_) }; | 141 | int const _at{ lua_gettop(K_) }; |
142 | for (int const _i : std::ranges::iota_view{ 1, std::min(count_, count) }) { // push val2 to valN | 142 | int const _count{ std::min(count_, count) }; |
143 | STACK_GROW(K_, _count); | ||
144 | for (int const _i : std::ranges::iota_view{ 1, _count }) { // push val2 to valN | ||
143 | lua_rawgeti(K_, 1, first + _i); // K_: fifo val2..N | 145 | lua_rawgeti(K_, 1, first + _i); // K_: fifo val2..N |
144 | } | 146 | } |
145 | lua_rawgeti(K_, 1, first); // push val1 // K_: fifo val2..N val1 | 147 | lua_rawgeti(K_, 1, first); // push val1 // K_: fifo val2..N val1 |