CID 22514: Out-of-bounds read (OVERRUN)

This commit is contained in:
Enno Rehling 2015-10-30 15:17:39 +01:00
parent 0da10ea490
commit a91a0f6a53
1 changed files with 4 additions and 3 deletions

View File

@ -169,12 +169,13 @@ void piracy_cmd(unit * u, order *ord)
if (saff != 0) {
saff = rng_int() % saff;
for (dir = 0; dir != MAXDIRECTIONS; ++dir) {
if (saff < aff[dir].value)
break;
saff -= aff[dir].value;
}
if (saff < aff[dir].value) {
target_dir = dir;
a_add(&r->attribs, mk_piracy(u->faction, aff[dir].target, target_dir));
break;
}
saff -= aff[dir].value;
}
}
}