From: david at dfoerster dot de Operating system: Linux PHP version: 5.2.5 PHP Bug Type: PCRE related Bug description: prep_replace returns null
Description: ------------ The preg_replace function returns null when a certain string is passed as haystack. Removing some lines from the string fixes the issue. The search pattern is not even found in the problematic string. This problem occurs with all PHP 5 versions I tested (5.2.0, 5.2.4, 5.2.5). It does not occur with PHP 4. (The search pattern uses back-references in case that matters.) Reproduce code: --------------- Run this script: http://dfoerster.de/misc/preg_replace_bug It prints the string length before and after the matching. With PHP 5 the length after the matching is 0, with PHP 4 it's the same as before as no replacement takes places. Expected result: ---------------- strlen returns the same length as before the matching. Actual result: -------------- strlen returns 0 after matching. -- Edit bug report at http://bugs.php.net/?id=43788&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43788&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43788&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43788&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43788&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=43788&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=43788&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=43788&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=43788&r=needscript Try newer version: http://bugs.php.net/fix.php?id=43788&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=43788&r=support Expected behavior: http://bugs.php.net/fix.php?id=43788&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=43788&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=43788&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=43788&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43788&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=43788&r=dst IIS Stability: http://bugs.php.net/fix.php?id=43788&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=43788&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=43788&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=43788&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=43788&r=mysqlcfg
