Bug #18428: ctype functions return TRUE on zero-length strings

From: Date: Fri, 19 Jul 2002 05:12:36 +0000
Subject: Bug #18428: ctype functions return TRUE on zero-length strings
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-14593@lists.php.net to get a copy of this message
From: busterb@mail.utexas.edu Operating system: Linux PHP version: 4CVS-2002-07-19 PHP Bug Type: Strings related Bug description: ctype functions return TRUE on zero-length strings The PHP ctype functions return TRUE when passed a zero length string. This is incorrect behavior; see the documentation for the contradiction. This is not an issue with the C ctype functions, since they deal with characters, which cannot be zero-length. The following patch corrects this behavior --- ctype.c 2002-07-18 23:58:02.000000000 -0500 +++ ctype_fixed.c 2002-07-18 23:57:48.000000000 -0500 @@ -102,8 +102,11 @@ { \ char *p; \ int n, len; \ - p=Z_STRVAL_P(c); \ len = Z_STRLEN_P(c); \ + if (!len) { \ + RETURN_FALSE; \ + } \ + p = Z_STRVAL_P(c); \ for(n=0;n<len;n++) { \ if(!iswhat(*p++)) RETURN_FALSE; \ } \ -- Edit bug report at http://bugs.php.net/?id=18428&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=18428&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=18428&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=18428&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=18428&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=18428&r=support Expected behavior: http://bugs.php.net/fix.php?id=18428&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=18428&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=18428&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=18428&r=globals

« previous php.bugs (#14593) next »