From: nhmall Date: Wed, 9 Feb 2022 10:47:08 +0000 (-0500) Subject: don't dereference NULL u.ustuck in dobuzz() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0e9ecb88fbf883350a9feb3c4c616a2e6282d5e3;p=nethack don't dereference NULL u.ustuck in dobuzz() --- diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index a81de9e4b..3c1026ccc 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -773,6 +773,7 @@ in flush_screen, reorder the code slightly to complete the bot() and magic traps can toggle intrinsic invisibility Death attacking a monster does drain life attack add unique Rider revival messages +don't dereference NULL u.ustuck in dobuzz() when hero has been swallowed Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/zap.c b/src/zap.c index e4497f382..d8b4089e2 100644 --- a/src/zap.c +++ b/src/zap.c @@ -4252,16 +4252,17 @@ dobuzz(int type, int nd, xchar sx, xchar sy, int dx, int dy, if (type < 0) return; tmp = zhitm(u.ustuck, type, nd, &otmp); - if (!u.ustuck) + if (!u.ustuck) { u.uswallow = 0; - else + } else { pline("%s rips into %s%s", The(fltxt), mon_nam(u.ustuck), exclam(tmp)); - /* Using disintegration from the inside only makes a hole... */ - if (tmp == MAGIC_COOKIE) - u.ustuck->mhp = 0; - if (DEADMONSTER(u.ustuck)) - killed(u.ustuck); + /* Using disintegration from the inside only makes a hole... */ + if (tmp == MAGIC_COOKIE) + u.ustuck->mhp = 0; + if (DEADMONSTER(u.ustuck)) + killed(u.ustuck); + } return; } if (type < 0)