Skip to content

Commit

Permalink
Fix the error check in FloodDecodePositions
Browse files Browse the repository at this point in the history
d'oh

This is functionally identical in all *happy path* cases (index 0 was
being falsely excluded, but it's one of the "seed" positions so it's
already been decoded), but making the completely wrong sanity check and
sending us into oob, undefined behavior territory.
  • Loading branch information
sz3 committed Feb 8, 2024
1 parent 97f4af3 commit 0fe367f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib/cimb_translator/FloodDecodePositions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ int FloodDecodePositions::update(unsigned index, const CellDrift& drift, unsigne
{
std::array<int,4> horizon = {-1, -1, -1, -1};
horizon[0] = _cellFinder.right(rridx);
if (horizon[0])
if (horizon[0] >= 0)
horizon[1] = _cellFinder.right(horizon[0]);
horizon[2] = _cellFinder.left(llidx);
if (horizon[2])
if (horizon[2] >= 0)
horizon[3] = _cellFinder.left(horizon[2]);

update_adjacents(horizon, drift, error_distance, cooldown);
Expand All @@ -118,10 +118,10 @@ int FloodDecodePositions::update(unsigned index, const CellDrift& drift, unsigne
{
std::array<int,4> vert = {-1, -1, -1, -1};
vert[0] = _cellFinder.top(uuidx);
if (vert[0])
if (vert[0] >= 0)
vert[1] = _cellFinder.top(vert[0]);
vert[2] = _cellFinder.bottom(ddidx);
if (vert[2])
if (vert[2] >= 0)
vert[3] = _cellFinder.bottom(vert[2]);

update_adjacents(vert, drift, error_distance, cooldown);
Expand Down

0 comments on commit 0fe367f

Please sign in to comment.