Skip to content

Commit 0d54b85

Browse files
authored
Fix bad index in removevalues (#571)
* Fix bad index in removevalues When the table.remove call from split into its own reverse iterating loop, the table.remove call was still using the `k` variable from the old loop rather than the new `i` index. * The for loop in removevalues should also break To match previous behavior, which was correct, the reverse iteration should also `break` so it doesn't needlessly try to match the entry that shifted into that index. No behavior change, as that entry would have already been checked and not matched. If the table only has one entry that is removed, this code would be indexing an empty table. * Embed scripts into scripts.c Run embed to inject fixes to removevalues
1 parent c4e45e2 commit 0d54b85

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

src/base/bake.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@
166166
for i = #tbl, 1, -1 do
167167
for _, pattern in ipairs(removes) do
168168
if pattern == tbl[i] then
169-
table.remove(tbl, k)
169+
table.remove(tbl, i)
170+
break
170171
end
171172
end
172173
end

0 commit comments

Comments
 (0)