summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelipe Pena <felipe@php.net>2010-11-06 18:32:10 +0000
committerFelipe Pena <felipe@php.net>2010-11-06 18:32:10 +0000
commitf4927c28bc3b1d7d50a81c9cd1655d003b4a8202 (patch)
treeb56cb35d5f44ab024c5285658c60d4aaec796adc
parent996f45b688b5d13b81a6bb8e33042a19efd7b130 (diff)
downloadphp-git-f4927c28bc3b1d7d50a81c9cd1655d003b4a8202.tar.gz
- Fixed bug #52732 (Docs say preg_match() returns FALSE on error, but it returns int(0))
patch by: slugonamission at gmail dot com
-rw-r--r--NEWS2
-rw-r--r--ext/pcre/php_pcre.c8
-rw-r--r--ext/pcre/tests/backtrack_limit.phpt2
-rw-r--r--ext/pcre/tests/bug52732.phpt13
-rw-r--r--ext/pcre/tests/invalid_utf8_offset.phpt2
-rw-r--r--ext/pcre/tests/recursion_limit.phpt2
6 files changed, 25 insertions, 4 deletions
diff --git a/NEWS b/NEWS
index 9065131c20..bdc615391e 100644
--- a/NEWS
+++ b/NEWS
@@ -106,6 +106,8 @@
get_class_name before calling it). (Kalle, Gustavo)
- Fixed bug #52744 (cal_days_in_month incorrect for December 1 BCE).
(gpap at internet dot gr, Adam)
+- Fixed bug #52732 (Docs say preg_match() returns FALSE on error, but it
+ returns int(0)). (slugonamission at gmail dot com)
- Fixed bug #52725 (gcc builtin atomic functions were sometimes used when they
were not available). (fat)
- Fixed bug #52745 (Binding params doesn't work when selecting a date inside a
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)