Skip to content

Commit

Permalink
heap-use-after-free after using scroll of food detection. Fixes #486
Browse files Browse the repository at this point in the history
  • Loading branch information
elunna committed Sep 27, 2023
1 parent 41f3fa3 commit dfbdd3b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/read.c
Original file line number Diff line number Diff line change
Expand Up @@ -2278,7 +2278,8 @@ struct obj *sobj; /* sobj - scroll or fake spellbook for spell */
case SPE_DETECT_FOOD: {
boolean failure;
failure = (food_detect(sobj) != 0);
if (!failure && sobj && sobj->blessed && monster_detect(sobj, S_BAD_FOOD))
if (!failure && sobj && sobj->blessed
&& (monster_detect(sobj, S_BAD_FOOD)== 0))
failure = FALSE;
if (failure) {
sobj = 0; /* failure: strange_feeling() -> useup() */
Expand Down

0 comments on commit dfbdd3b

Please sign in to comment.