mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
- Fixed bug #52732 (Docs say preg_match() returns FALSE on error, but it returns int(0))
patch by: slugonamission at gmail dot com
This commit is contained in:
parent
ccfe9c30aa
commit
03cbbf4348
5 changed files with 23 additions and 4 deletions
|
@ -754,7 +754,13 @@ PHPAPI void php_pcre_match_impl(pcre_cache_entry *pce, char *subject, int subjec
|
|||
efree(offsets);
|
||||
efree(subpat_names);
|
||||
|
||||
RETVAL_LONG(matched);
|
||||
/* Did we encounter an error? */
|
||||
if(PCRE_G(error_code) == PHP_PCRE_NO_ERROR) {
|
||||
RETVAL_LONG(matched);
|
||||
}
|
||||
else {
|
||||
RETVAL_FALSE;
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ var_dump(preg_last_error() === PREG_NO_ERROR);
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(true)
|
||||
int(10)
|
||||
bool(true)
|
||||
|
|
13
ext/pcre/tests/bug52732.phpt
Normal file
13
ext/pcre/tests/bug52732.phpt
Normal file
|
@ -0,0 +1,13 @@
|
|||
--TEST--
|
||||
Bug #52732 (Docs say preg_match() returns FALSE on error, but it returns int(0))
|
||||
--INI--
|
||||
pcre.backtrack_limit=1
|
||||
--FILE--
|
||||
<?php
|
||||
$ret = preg_match('/(?:\D+|<\d+>)*[!?]/', 'foobar foobar foobar');
|
||||
|
||||
var_dump($ret);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
bool(false)
|
|
@ -22,7 +22,7 @@ var_dump(preg_last_error() == PREG_NO_ERROR);
|
|||
echo "Done\n";
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
||||
bool(false)
|
||||
array(0) {
|
||||
}
|
||||
bool(true)
|
||||
|
|
|
@ -19,7 +19,7 @@ var_dump(preg_last_error() === PREG_NO_ERROR);
|
|||
|
||||
?>
|
||||
--EXPECT--
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(true)
|
||||
int(1)
|
||||
bool(true)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue