Skip to content

Commit

Permalink
protect against out of range vector access in modded games
Browse files Browse the repository at this point in the history
where there are invalid plant indices in the Wood vector
  • Loading branch information
myk002 committed Sep 2, 2023
1 parent 7486df2 commit a742443
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Template for new versions:
- `fix/retrieve-units`: fix retrieved units sometimes becoming duplicated on the map
- `quickfort`: cancel old dig jobs that point to a tile when a new designation is applied to the tile
- `gui/launcher`, `gui/gm-editor`: recover gracefully when the saved frame position is now offscreen
- `gui/sandbox`: correctly load equipment materials in modded games that categorize non-wood plants as wood

## Misc Improvements
- `devel/lsmem`: added support for filtering by memory addresses and filenames
Expand Down
2 changes: 2 additions & 0 deletions gui/sandbox.lua
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,14 @@ local function scan_organic(cat, vec, start_idx, base, do_insert)
local indexes = MAT_TABLE.organic_indexes[cat]
for idx = start_idx,#indexes-1 do
local matindex = indexes[idx]
if #vec <= matindex then goto continue end
local organic = vec[matindex]
for offset, mat in ipairs(organic.material) do
if do_insert(mat, base + offset, matindex) then
return matindex
end
end
::continue::
end
return 0
end
Expand Down

0 comments on commit a742443

Please sign in to comment.