From:             jm at mayfirst dot org
Operating system: gnu linux/debian sid
PHP version:      5.2.4
PHP Bug Type:     PCRE related
Bug description:  preg_replace returns empty string

Description:
------------
When executing preg_replace on a string over 32,205 bytes and no double
line breaks with the following expression, the function neither matches nor
returns the original string. preg_last_error() doesn't indicate any  preg
related errors.

Reproduce code:
---------------
 error_reporting(E_ALL);
  $original_string = "This is a preg_replace bug.\n";
  $string = '';
  $i = 0;
  while($i < 1177) {
    $string .= $original_string;
    preg_replace('/\n?(.+?)(?:\n\s*\n|\z)/s', "foo", $string,-1,$count);
    if($count == 0) {
      echo "I broke at count: $i\n";
      exit;
    }
    $i++;
  }
  echo "I didn't break at count: $i\n";
  echo preg_last_error();


Expected result:
----------------
I didn't break at count: 1176.

Actual result:
--------------
I broke at count: 1176

-- 
Edit bug report at http://bugs.php.net/?id=42806&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=42806&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=42806&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=42806&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=42806&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=42806&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=42806&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=42806&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=42806&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=42806&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=42806&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=42806&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=42806&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=42806&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=42806&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=42806&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=42806&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=42806&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=42806&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=42806&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=42806&r=mysqlcfg

Reply via email to