Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix potential out-of-bounds array index
  • Loading branch information
Zeno- committed Jan 16, 2015
1 parent 5aeeb21 commit 5e58a95
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mapblock_mesh.cpp
Expand Up @@ -346,15 +346,15 @@ void finalColorBlend(video::SColor& result,
1, 4, 6, 6, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
b += emphase_blue_when_dark[b / 8];
b = irr::core::clamp (b, 0, 255);
b += emphase_blue_when_dark[irr::core::clamp(b, 0, 255) / 8];
b = irr::core::clamp(b, 0, 255);

// Artificial light is yellow-ish
static const u8 emphase_yellow_when_artificial[16] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 10, 15, 15, 15
};
rg += emphase_yellow_when_artificial[night/16];
rg = irr::core::clamp (rg, 0, 255);
rg = irr::core::clamp(rg, 0, 255);

result.setRed(rg);
result.setGreen(rg);
Expand Down

0 comments on commit 5e58a95

Please sign in to comment.