Bug #77146 [Com]: feof not reached

From: Date: Tue, 13 Nov 2018 13:22:13 +0000
Subject: Bug #77146 [Com]: feof not reached
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217927@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77146&edit=1 ID: 77146 Comment by: tpojka at gmail dot com Reported by: samuel dot chemla at orange dot com Summary: feof not reached Status: Open Type: Bug Package: Streams related Operating System: Windows 7 x64 PHP Version: 7.0.32 Block user comment: N Private report: N New Comment: For sake of consistency it should be in line: $data = "foo"; $stream = fopen('php://memory', 'r+'); fwrite($stream, $data); fseek($stream, 0); if ($data !== fread($stream, strlen($data)+1)) { throw new \Exception("Invalid read"); } if (strlen($data) !== ftell($stream)) { throw new \Exception("Invalid tell"); } if (feof($stream) !== true) { throw new \Exception("Invalid eof"); } Previous Comments: ------------------------------------------------------------------------ [2018-11-13 12:53:08] samuel dot chemla at orange dot com Description: ------------ feof return false when it should return true. See script below. This bug is only on 7.0.32. I tested on 7.2.9 and it works perfectly. I filled this report because not reaching eof may be dangerous. Test script: --------------- $data = "foo"; $stream = fopen('php://memory', 'r+'); fwrite($stream, $data); fseek($stream, 0); if ($data !== fread($stream, strlen($data)+1)) { throw new \Exception("Invalid data"); } if (strlen($data) !== ftell($stream)) { throw new \Exception("Invalid tell"); } if (feof($stream) !== true) { throw new \Exception("Invalid eof"); } Expected result: ---------------- <No exception> Actual result: -------------- \Exception("Invalid eof") raised ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=77146&edit=1

« previous php.bugs (#217927) next »