]> granicus.if.org Git - nethack/commit
fix github issue #302 - divide by 0 crash
authorPatR <rankin@nethack.org>
Sat, 22 Feb 2020 09:41:04 +0000 (01:41 -0800)
committernhmall <nhmall@nethack.org>
Wed, 4 Mar 2020 20:57:33 +0000 (15:57 -0500)
commit60bc28154ab63c294bab3bc8ec0c603eb5cfca3f
tree4ebbf180bd00fc03530460703d58eb6a3885fe48
parent7220c9d2d2353ed9c9625bbb7f86df1d0af5ed37
fix github issue #302 - divide by 0 crash

The traceback points directly to the problem:  divide by 0 happens
if the 'bogusmon' file only contains the "do not edit" line, which
would happen if 'bogusmon.txt' is empty.  makedefs probably ought to
complain about that.

There is now one hardcoded bogus monster to fall back to:  'bogon'.

Random tombstone epitaphs report divide by 0 if their text source is
empty, but it is done by rn2() rather than rn2_for_display_rng() so
is just a warning for pre-release code.  It would crash for release
version though.

I tried placing an empty engravings file and expected similar results
but didn't see any response.  Not sure what that means.

After the fix, empty epitaph file yields blank result so graves that
want a random epitaph won't have any epitaph.

Fixes #302
src/do_name.c
src/rumors.c