|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-05-20 10:19 UTC] nlopess@php.net
[2007-05-21 01:08 UTC] judas dot iscariote at gmail dot com
[2007-05-21 08:57 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 14:00:01 2025 UTC |
Description: ------------ The following source gives segfault on CentOS 4.3 64-Bit and PHP 5.2.2. Don't be scared, this regular expression is real parser for my templates-engine, and it works with other operation systems. The result depends on Subject, so with '$var' it works well, but if '$var[anything]' then crashes. Reproduce code: --------------- <?php echo 'proof of compilation'."\n"; preg_replace( '~(([\'"]).*?(?<!\\\\)\2|\w*\s*\(((?:(?R)|.)*?)\)' .'|[\$#]\w+#?(?:\\[(?:(?R)|((?:[^\\]\'"]*(?:([\'"]).*?(?<!\\\\)\5)?)*))*?\\]|\.[\$#]?\w+#?|->\s*[\$#]?\w+(?:\(((?:(?R)|.)*?)\))?)*' .'|-?\d+|(?<=^|[\s\)\:\.=+\-<>])(?:\w+)(?=$|[\s\|\.\:\(=+\-<>]))(\s+(?:is(?:\s+not)?\s+(?:odd|div|even)\s+by\s+-?\d+|is(?:\s+not)?\s+(?:odd|even)))?((?:\|@?\w+(?:\\:(?:'.'\w*\(((?:(?R)|.)*?)\)|[\$#]\w+#?(?:\\[(?:(?R)|((?:[^\\]\'"]*(?:([\'"]).*?(?<!\\\\)\11)?)*))*?\\]|\.[\$#]?\w+#?)*|[^\'"\:]*(?:[^\'"\:]*([\'"]).*?(?<!\\\\)\12[^\'"\:]*)*'.'))*)*)' .'|((?<=\s|\))(?:is\s+not|is|not\s+eq|eq|neq?|gt|lt|gt?e|ge|lt?e|mod)(?=\s|\()|(?:not\s+))' .'~si','any replacement','$var[index]'); Expected result: ---------------- "any replacement" Actual result: -------------- [root@72 _test]# php -q bug.php proof of compilation Segmentation fault