|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patch preg_match_false_on_error for PCRE related Bug #52732Patch version 2010-10-07 13:39 UTC Return to Bug #52732 | Download this patchThis patch renders other patches obsolete Obsolete patches: Patch Revisions:Developer: slugonamission@gmail.com
Index: ext/pcre/php_pcre.c
===================================================================
--- ext/pcre/php_pcre.c (revision 304164)
+++ ext/pcre/php_pcre.c (working copy)
@@ -754,7 +754,13 @@
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: ext/pcre/tests/bug52732.phpt
===================================================================
--- ext/pcre/tests/bug52732.phpt (revision 0)
+++ ext/pcre/tests/bug52732.phpt (revision 0)
@@ -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: ext/pcre/tests/backtrack_limit.phpt
===================================================================
--- ext/pcre/tests/backtrack_limit.phpt (revision 304164)
+++ ext/pcre/tests/backtrack_limit.phpt (working copy)
@@ -19,7 +19,7 @@
?>
--EXPECT--
-int(0)
+bool(false)
bool(true)
int(10)
bool(true)
Index: ext/pcre/tests/invalid_utf8_offset.phpt
===================================================================
--- ext/pcre/tests/invalid_utf8_offset.phpt (revision 304164)
+++ ext/pcre/tests/invalid_utf8_offset.phpt (working copy)
@@ -22,7 +22,7 @@
echo "Done\n";
?>
--EXPECT--
-int(0)
+bool(false)
array(0) {
}
bool(true)
Index: ext/pcre/tests/recursion_limit.phpt
===================================================================
--- ext/pcre/tests/recursion_limit.phpt (revision 304164)
+++ ext/pcre/tests/recursion_limit.phpt (working copy)
@@ -19,7 +19,7 @@
?>
--EXPECT--
-int(0)
+bool(false)
bool(true)
int(1)
bool(true)
|
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 08:00:01 2025 UTC |