note 41717 deleted from function.preg-match by aidan
| From: | aidan@php.net | Date: | Sun, 04 Jul 2004 16:22:10 +0000 |
| Subject: | note 41717 deleted from function.preg-match by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72531@lists.php.net to get a copy of this message | ||
Note Submitter: dev@popfactory.com
----
As Brion noticed in a previous note, preg_match function may CRASH php apache module (it
doesn't seem to happen in CLI version) if you use this function with a null pattern :
<?php
if( some conditions ) {
$pattern = 'something';
...
}
...
preg_match($pattern,$subject,$matches);
// THIS MAY CRASH !
php?>
To avoid crashes, be sure that $pattern has been defined before using preg_match :
<?php
if( some conditions ) {
$pattern = 'something';
...
}
...
if($pattern) { // $pattern is not null or empty
preg_match($pattern,$subject,$matches);
}
...
php?>