static analyzer bit for artifact.c

src/artifact.c(1589): warning C6011: Dereferencing NULL pointer 'magr'.

The 'struct monst *magr' parameter to artifact_hit() can be Null
if 'mdef' is youmonst. mdef is nonnull.
This commit is contained in:
nhmall
2023-12-23 22:55:14 -05:00
parent 7e131649c4
commit 93bcfeac29
2 changed files with 2 additions and 1 deletions

View File

@@ -1586,6 +1586,7 @@ artifact_hit(
if (youattack) {
healup(drain, 0, FALSE, FALSE);
} else {
assert(magr != 0);
magr->mhp += drain;
if (magr->mhp > magr->mhpmax)
magr->mhp = magr->mhpmax;