summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Alexandra Katz <beeswaxboffin@gmail.com>2019-11-03 16:45:33 -0500
committerBardur Arantsson <bardur@scientician.net>2020-01-31 16:16:30 +0100
commit7829a67b588da07c000cbe789bb3ed0e332acc67 (patch)
treedb2fa6ab6b01b916b51d0885af277fc56399571d
parent373489f1a64ce8ebf9e18f3fb613118987867c6f (diff)
Implement bounds checking when selecting a corruption
-rw-r--r--src/corrupt.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/corrupt.cc b/src/corrupt.cc
index 95a29343..b11f161c 100644
--- a/src/corrupt.cc
+++ b/src/corrupt.cc
@@ -801,7 +801,7 @@ static void player_lose_corruption(int corruption_idx)
*/
static bool test_depend_corrupt(s16b corrupt_idx, bool can_gain)
{
- s16b i;
+ size_t i;
corruption_type *c_ptr = NULL;
assert(corrupt_idx >= 0);
@@ -823,7 +823,7 @@ static bool test_depend_corrupt(s16b corrupt_idx, bool can_gain)
}
/* Go through all dependencies */
- for (i=0; c_ptr->depends[i] >= 0; i++)
+ for (i=0; i < std::size(c_ptr->depends) && c_ptr->depends[i] >= 0; i++)
{
if (!test_depend_corrupt(c_ptr->depends[i], false))
{
@@ -832,7 +832,7 @@ static bool test_depend_corrupt(s16b corrupt_idx, bool can_gain)
}
/* Go through all opposers */
- for (i=0; c_ptr->opposes[i] >= 0; i++)
+ for (i=0; i < std::size(c_ptr->depends) && c_ptr->opposes[i] >= 0; i++)
{
if (test_depend_corrupt(c_ptr->opposes[i], false))
{