Bug #71905 [NEW]: invalid switch case is returning valid
| From: | pat at breakfree dot com | Date: | Sat, 26 Mar 2016 14:28:22 +0000 |
| Subject: | Bug #71905 [NEW]: invalid switch case is returning valid | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-200114@lists.php.net to get a copy of this message | ||
From: pat at breakfree dot com
Operating system: Ubuntu 14.04
PHP version: 5.5.33
Package: *Programming Data Structures
Bug Type: Bug
Bug description:invalid switch case is returning valid
Description:
------------
A false switch case is returning valid.
Perhaps related to key index returned from stat()?
PHP 5.5.9-1ubuntu4.14 (cli) (built: Oct 28 2015 01:34:46)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend
Technologies
Test script:
---------------
<?php
$s = stat('/tmp');
/*
* I was interested in data from a few keys. However I found the 0/dev
key is always resulting as a true case.
*/
$x = 0;
foreach($s as $k => $v) {
switch($k) {
case 'this_does_not_exist_and_should_never_occur':
echo 'Yet this case occurs: ' . $k . ', ' . $v . "\n";
$x++;
break;
default:
break;
}
}
echo "x=" . $x . "\n";
?>
Expected result:
----------------
x=0
Actual result:
--------------
Yet this case occurs: 0, 64769
x=1
--
Edit bug report at https://bugs.php.net/bug.php?id=71905&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=71905&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=71905&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=71905&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=71905&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=71905&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=71905&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=71905&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=71905&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=71905&r=support
Expected behavior: https://bugs.php.net/fix.php?id=71905&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=71905&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=71905&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=71905&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=71905&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=71905&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=71905&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=71905&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=71905&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=71905&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=71905&r=mysqlcfg