- 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:
Felipe Pena 2010-11-06 18:32:10 +00:00
parent ccfe9c30aa
commit 03cbbf4348
5 changed files with 23 additions and 4 deletions

View file

@ -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;
}
}
/* }}} */

View file

@ -19,7 +19,7 @@ var_dump(preg_last_error() === PREG_NO_ERROR);
?>
--EXPECT--
int(0)
bool(false)
bool(true)
int(10)
bool(true)

View 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)

View file

@ -22,7 +22,7 @@ var_dump(preg_last_error() == PREG_NO_ERROR);
echo "Done\n";
?>
--EXPECT--
int(0)
bool(false)
array(0) {
}
bool(true)

View file

@ -19,7 +19,7 @@ var_dump(preg_last_error() === PREG_NO_ERROR);
?>
--EXPECT--
int(0)
bool(false)
bool(true)
int(1)
bool(true)