Advanced Rogue 7: fix a crash when casting magic missile.

do_zap() dereferenced a struct object pointer while ignoring the result
of a NULL check.  XRogue had the same problem, though triggering it was
unlikely, since XRogue does not include a magic missile spell.

Reported by John Harris of @Play.
This commit is contained in:
John "Elwin" Edwards 2021-10-21 21:00:15 -04:00
parent fb0ef69143
commit b6067e102e
2 changed files with 2 additions and 2 deletions

View file

@ -309,7 +309,7 @@ do_zap(struct thing *zapper, struct object *obj, coord *direction, int which,
if (!obj)
dice = zapper->t_stats.s_lvl;
if (obj->o_type == RELIC)
else if (obj->o_type == RELIC)
dice = 15;
else if (EQUAL(ws_type[which], "staff"))
dice = 10;

View file

@ -323,7 +323,7 @@ do_zap(struct thing *zapper, struct object *obj, coord *direction, int which,
if (!obj)
dice = zapper->t_stats.s_lvl;
if (obj->o_type == RELIC)
else if (obj->o_type == RELIC)
dice = 15;
else if (EQUAL(ws_type[which], "staff"))
dice = 10;