]> granicus.if.org Git - php/commitdiff
- Fixed bug #52732 (Docs say preg_match() returns FALSE on error, but it returns...
authorFelipe Pena <felipe@php.net>
Sat, 6 Nov 2010 18:32:10 +0000 (18:32 +0000)
committerFelipe Pena <felipe@php.net>
Sat, 6 Nov 2010 18:32:10 +0000 (18:32 +0000)
  patch by: slugonamission at gmail dot com

NEWS
ext/pcre/php_pcre.c
ext/pcre/tests/backtrack_limit.phpt
ext/pcre/tests/bug52732.phpt [new file with mode: 0644]
ext/pcre/tests/invalid_utf8_offset.phpt
ext/pcre/tests/recursion_limit.phpt

diff --git a/NEWS b/NEWS
index 9065131c206369ec5fcbf9c377f628dfb58b8d5f..bdc615391e85511a850c146bda732cba72951e50 100644 (file)
--- a/NEWS
+++ b/NEWS
   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
index ccb0a51c0ec840e9767c1e3c5f3eab4f38c535df..ef7e051d8632dacb74743e2a272c0f979e03cbf9 100644 (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;
+       }
 }
 /* }}} */
 
index 517e7270163969222d1adb26e98a2ab7d5f05ffe..419e6c20090ad385419023bea517ef8fc69438f0 100644 (file)
@@ -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 (file)
index 0000000..8cfa204
--- /dev/null
@@ -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
index b6ec1e596fa2a98183262121ba92f1ae7344f119..50716ca9b2578577ab5ec1fc5316eb2ecb765cd0 100644 (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)
index 9933b5c4d780e1846ab7f2c25046b8c4ee60c721..7dee7ba4e7236e640e7b0337d74ecc4e2ca7faee 100644 (file)
@@ -19,7 +19,7 @@ var_dump(preg_last_error() === PREG_NO_ERROR);
 
 ?>
 --EXPECT--
-int(0)
+bool(false)
 bool(true)
 int(1)
 bool(true)