potential ctype.h issues

A few things which might conceivably pass negative values to ctype
routines.  Some are post-3.6.0.  None of them explain the sporadic
Windows assertion failure.

Using tolower() without verifying the argument isupper() should be
completely safe when tolower() is a function but might not be when
it's a macro.  (Likewise for toupper() without islower().)  NetHack's
lowc() function is always safe, at least for ASCII.
This commit is contained in:
PatR
2016-05-22 17:29:59 -07:00
parent c1bfa1360f
commit bc91a01fdd
2 changed files with 34 additions and 31 deletions

View File

@@ -1468,7 +1468,7 @@ rndmonst()
rndmonst_state.mchoices[mndx] = 0;
if (tooweak(mndx, minmlev) || toostrong(mndx, maxmlev))
continue;
if (upper && !isupper(def_monsyms[(int) (ptr->mlet)].sym))
if (upper && !isupper((uchar) def_monsyms[(int) ptr->mlet].sym))
continue;
if (elemlevel && wrong_elem_type(ptr))
continue;