ID:               44764
 Updated by:       [EMAIL PROTECTED]
 Reported By:      steemann at globalpark dot de
-Status:           Open
+Status:           Bogus
-Bug Type:         *Regular Expressions
+Bug Type:         PCRE related
 Operating System: Linux rom 2.4.21-297-smp4G
 PHP Version:      5.2.5
 New Comment:

This is expected. The reason can be known using preg_last_error(), that
in the case returns 2. (2 = PREG_BACKTRACK_LIMIT_ERROR)

http://docs.php.net/manual/en/pcre.configuration.php#ini.pcre.backtrack-limit


Previous Comments:
------------------------------------------------------------------------

[2008-04-17 18:14:17] steemann at globalpark dot de

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) {
}



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=44764&edit=1

Reply via email to