Browse Source

Fix OOB in DrawSpell (#405)

The OOB here was in `_pSplLvl[spl]`.

The value of SPL_INVALID is is `-1`.
The fix is to not access the array when `spl == SPL_INVALID`.
pull/409/head
Gleb Mazovetskiy 7 years ago committed by Anders Jenbo
parent
commit
b18fe49d0a
  1. 8
      Source/control.cpp

8
Source/control.cpp

@ -226,15 +226,15 @@ void SetSpellTrans(char t)
*/
void DrawSpell()
{
char spl, st;
int tlvl;
char st;
int spl, tlvl;
spl = plr[myplr]._pRSpell;
st = plr[myplr]._pRSplType;
// BUGFIX: Move the next line into the if statement to avoid OOB (SPL_INVALID is -1)
tlvl = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[spl];
// BUGFIX: Move the next line into the if statement to avoid OOB (SPL_INVALID is -1) (fixed)
if (st == RSPLTYPE_SPELL && spl != SPL_INVALID) {
tlvl = plr[myplr]._pISplLvlAdd + plr[myplr]._pSplLvl[spl];
if (!CheckSpell(myplr, spl, RSPLTYPE_SPELL, TRUE))
st = RSPLTYPE_INVALID;
if (tlvl <= 0)

Loading…
Cancel
Save