diff options
Diffstat (limited to 'ext/pcre')
| -rw-r--r-- | ext/pcre/php_pcre.c | 8 | ||||
| -rw-r--r-- | ext/pcre/tests/backtrack_limit.phpt | 2 | ||||
| -rw-r--r-- | ext/pcre/tests/bug52732.phpt | 13 | ||||
| -rw-r--r-- | ext/pcre/tests/invalid_utf8_offset.phpt | 2 | ||||
| -rw-r--r-- | ext/pcre/tests/recursion_limit.phpt | 2 |
5 files changed, 23 insertions, 4 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index ccb0a51c0e..ef7e051d86 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -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; + } } /* }}} */ diff --git a/ext/pcre/tests/backtrack_limit.phpt b/ext/pcre/tests/backtrack_limit.phpt index 517e727016..419e6c2009 100644 --- a/ext/pcre/tests/backtrack_limit.phpt +++ b/ext/pcre/tests/backtrack_limit.phpt @@ -19,7 +19,7 @@ var_dump(preg_last_error() === PREG_NO_ERROR); ?> --EXPECT-- -int(0) +bool(false) bool(true) int(10) bool(true) diff --git a/ext/pcre/tests/bug52732.phpt b/ext/pcre/tests/bug52732.phpt new file mode 100644 index 0000000000..8cfa20420f --- /dev/null +++ b/ext/pcre/tests/bug52732.phpt @@ -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)
\ No newline at end of file diff --git a/ext/pcre/tests/invalid_utf8_offset.phpt b/ext/pcre/tests/invalid_utf8_offset.phpt index b6ec1e596f..50716ca9b2 100644 --- a/ext/pcre/tests/invalid_utf8_offset.phpt +++ b/ext/pcre/tests/invalid_utf8_offset.phpt @@ -22,7 +22,7 @@ var_dump(preg_last_error() == PREG_NO_ERROR); echo "Done\n"; ?> --EXPECT-- -int(0) +bool(false) array(0) { } bool(true) diff --git a/ext/pcre/tests/recursion_limit.phpt b/ext/pcre/tests/recursion_limit.phpt index 9933b5c4d7..7dee7ba4e7 100644 --- a/ext/pcre/tests/recursion_limit.phpt +++ b/ext/pcre/tests/recursion_limit.phpt @@ -19,7 +19,7 @@ var_dump(preg_last_error() === PREG_NO_ERROR); ?> --EXPECT-- -int(0) +bool(false) bool(true) int(1) bool(true) |
