From: giovanni at giacobbi dot net Operating system: Linux PHP version: 4.3.4 PHP Bug Type: Scripting Engine problem Bug description: invalid fgets() return value when invalid resource supplied
Description: ------------ See the example code. It should return FALSE according to the manual (and to common good sense). This is causing valid code like while (($str = fgets($fd)) !== FALSE) { ... } to go into infinite loop, which is very bad. I tried to look at the source code but it looks correct, as it should fall in file.c:1395, at the exit_failed label. Reproduce code: --------------- <?php $fd = FALSE; $retval = @fgets($fd); var_dump($retval); Expected result: ---------------- FALSE Actual result: -------------- NULL -- Edit bug report at http://bugs.php.net/?id=26772&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26772&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26772&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=26772&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=26772&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=26772&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=26772&r=needscript Try newer version: http://bugs.php.net/fix.php?id=26772&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=26772&r=support Expected behavior: http://bugs.php.net/fix.php?id=26772&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=26772&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=26772&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=26772&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26772&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=26772&r=dst IIS Stability: http://bugs.php.net/fix.php?id=26772&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=26772&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=26772&r=float