reinstate removal of mon guard from is_safemon()

callers were checked:
domove_attackmon_at(mtmp, x, y, displaceu) has mtmp declared nonnull;
    there are dereferences of mtmp in the first line of code in
    the function.

In domove_core():
    The 1st occurrence of is_safemon(mtmp) is guarded by if (mtmp) { }.
    The 2nd occurrence of is_safemon(mtmp) is inside an if (mtmp) { } block.
    The 3rd occurrence of is_safemon(mtmp) was just remediated by 987be7e8.

In lookaround():
    The only occurrence of is_safemon(mtmp) is inside an
        if ((mtmp = m_at(x, y)) != 0 [...] { } block.

In do_attack(mtmp), in uhitm.c:
    The parameter is declared NONNULLARG1, and the 1st line of
    code contains a dereference with mtmp->data, which would
    segfault if mtmp were NULL.
This commit is contained in:
nhmall
2023-12-16 12:37:49 -05:00
parent 987be7e8e5
commit 294ce9b59d
2 changed files with 2 additions and 1 deletions

View File

@@ -157,7 +157,7 @@
* definition here is convenient. No longer limited to pets.
*/
#define _is_safemon(mon) \
(flags.safe_dog && (mon) && (mon)->mpeaceful && canspotmon(mon) \
(flags.safe_dog && (mon)->mpeaceful && canspotmon(mon) \
&& !Confusion && !Hallucination && !Stunned)
/*