fix #K1963 - warning after placing worm tail
Report described this as a panic triggered by the sanity_check option, but that's because it was running under the fuzzer, which escalates any impossible() to panic(), rather than because nethack panicked. I couldn't find anything wrong--which doesn't mean that there isn't something wrong--with place_worm_tail_randomly() and random_dir(). They use xchar for map coordinates which should be fine as long as no negative values are generated and I couldn't discover any such. The suggested fix of changing xchar to int might indicate a compiler bug (although the odds of that are low). The bogus coordinate of -15000 in the report suggests that typedef short int schar; (which changes xchar too) is being used in the configuration but I don't recall having any problems attributable to that. This switches from xchar to int as a side-effect of replacing the offending code entirely. The new code might produce an 'ny' of -1 before goodpos() rejects it, so xchar would be inappropriate now. The old code is commented out via #if 0 _after_ changing it from xchar to int. This also adds an extra sanity_check for worm tails, unrelated to the current bug. I'm not aware of any instance where it fails. EXTRA_SANITY_CHECKS needs to be defined for it to do anything.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 extern.h $NHDT-Date: 1597069374 2020/08/10 14:22:54 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.855 $ */
|
||||
/* NetHack 3.7 extern.h $NHDT-Date: 1599559379 2020/09/08 10:02:59 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.856 $ */
|
||||
/* Copyright (c) Steve Creps, 1988. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -3078,6 +3078,7 @@ E void FDECL(save_worm, (NHFILE *));
|
||||
E void FDECL(rest_worm, (NHFILE *));
|
||||
E void FDECL(place_wsegs, (struct monst *, struct monst *));
|
||||
E void FDECL(sanity_check_worm, (struct monst *));
|
||||
E void NDECL(wormno_sanity_check);
|
||||
E void FDECL(remove_worm, (struct monst *));
|
||||
E void FDECL(place_worm_tail_randomly, (struct monst *, XCHAR_P, XCHAR_P));
|
||||
E int FDECL(size_wseg, (struct monst *));
|
||||
|
||||
Reference in New Issue
Block a user