Bug #76901 [Ver->Csd]: method_exists on SPL iterator passthrough method corrupts memory

From: Date: Wed, 19 Sep 2018 07:41:44 +0000
Subject: Bug #76901 [Ver->Csd]: method_exists on SPL iterator passthrough method corrupts memory
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-217136@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76901&edit=1 ID: 76901 Updated by: nikic@php.net Reported by: p dot bytniewski at neurosys dot com Summary: method_exists on SPL iterator passthrough method corrupts memory -Status: Verified +Status: Closed Type: Bug Package: SPL related Operating System: Linux - debian based PHP Version: 7.2.10 Assigned To: nikic Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=294fb83ee84b76479a62e4ed37d5523c1208ad7c Log: Fixed bug #76901 Previous Comments: ------------------------------------------------------------------------ [2018-09-19 07:36:43] a at b dot c dot de Also happens under Windows 10; except there is no fatal error reported; also affects $iterator->getSubPath(); garbage varies from run to run. With a slightly deeper directory tree: . └───directory ├───dir │ └───again │ ├───file3.txt │ ├───file4.txt │ └───file5.txt └───subdirectory ├───file1.txt └───file2.txt The result is: dir\again\file3.txt @1Gl\file4.txt subdirectory\file1.txt ` @l\file2.txt ------------------------------------------------------------------------ [2018-09-19 06:14:33] p dot bytniewski at neurosys dot com Description: ------------ Having the following directory structure: ./directory ./directory/subdirectory ./directory/subdirectory/file2 ./directory/subdirectory/file1 when executing the provided test script, after encountering second file there seems to be some corruption. If there's no call to method_exists, everything works fine. Test script: --------------- <?php $path = 'directory'; $iterator = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS) ); foreach($iterator as $it) { if (!method_exists($iterator, 'getSubPathName')) { throw new \LogicException('This should never happen'); } echo $iterator->getSubPathName(). PHP_EOL; } Expected result: ---------------- subdirectory/file2 subdirectory/file1 Actual result: -------------- subdirectory/file2 pf��/file1 PHP Fatal error: Couldn't execute method RecursiveDirectoryIterator::next in Unknown on line 0 PHP Stack trace: PHP 1. {main}() path/to/file/iterator.php:0 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=76901&edit=1

« previous php.bugs (#217136) next »