|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-04-17 18:36 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 20:00:01 2025 UTC |
Description: ------------ When passing somewhat long strings to the first two parameters of preg_match, the function result reproducibly changes to an empty array if the one the strings gets too long. The reproduce code works on PHP 5.1.4 CLI, but not on PHP 5.2.4 and PHP 5.2.5 CLI. When changing the string length of 1536 into 1535, the code also works fine in PHP 5.2.x. This affects the seconds parameter of preg_match. If the 1536 in the reproduce code is reduced to 1535, the code will work again. But if then the number of iterations in the for loop is changed from 64 to 65 iterations, the code will misbehave again (returning the empty array). Seems to be some length overflow somewhere. Reproduce code: --------------- $parts=array(); for ($i=1;$i<=64;$i++) { $parts[]="#".$i."#"; } preg_match("/^(.*)(".implode("|",$parts).")/",$parts[0].str_repeat(" ",1536),$matches); var_dump($matches); Expected result: ---------------- array(3) { [0]=> string(3) "#1#" [1]=> string(0) "" [2]=> string(3) "#1#" } Actual result: -------------- array(0) { }