Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.7.2

Bug #13849 infinite loop in PHP_CodeSniffer_File::findNext()
Submitted: 2008-05-08 03:03 UTC
From: jablko Assigned: squiz
Status: Closed Package: PHP_CodeSniffer (version CVS)
PHP Version: 5.2.5 OS:
Roadmaps: 1.1.0    
Subscription  


 [2008-05-08 03:03 UTC] jablko (Jack Bates)
Description: ------------ Our code audit recently started going into an infinite loop. I traced the problem to Squiz_Sniffs_ControlStructures_ForLoopDeclarationSniff::process() line 82: $firstSemicolon = $phpcsFile->findNext(T_SEMICOLON, $openingBracket); If $openingBracket === false, PHP_CodeSniffer_File::findNext() will go into an infinite loop at line 1867: for ($i = $start; $i < $end; $i++) { - because $i++ will always === false I can reproduce the error by running the Squiz_Sniffs_ControlStructures_ForLoopDeclarationSniff on the following (invalid) PHP source: --- <?php for --- Thanks and best wishes, Jack

Comments

 [2008-05-08 03:32 UTC] squiz (Greg Sherwood)
Do you happen to have any valid code that makes it break? If so, I can put it into a unit test.
 [2008-05-08 03:38 UTC] squiz (Greg Sherwood)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. I've handled this case and added a new warning of a possible parse error.