Skip to content

Commit 8cac830

Browse files
nielsdosGirgias
authored andcommitted
Fix incorrect error check in browsecap for pcre2_match()
pcre2_match() returns error codes < 0, but only the "no match" error code was handled. Fix it by changing the check to >= 0. Closes GH-10632 Signed-off-by: George Peter Banyard <girgias@php.net>
1 parent f592f75 commit 8cac830

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ PHP NEWS
5959
. Fix incorrect check in cs_8559_5 in map_from_unicode(). (nielsdos)
6060
. Fix bug GH-9697 for reset/end/next/prev() attempting to move pointer of
6161
properties table for certain internal classes such as FFI classes
62+
. Fix incorrect error check in browsecap for pcre2_match(). (nielsdos)
6263

6364
- Tidy:
6465
. Fix memory leaks when attempting to open a non-existing file or a file over

ext/standard/browscap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ static int browser_reg_compare(browscap_entry *entry, zend_string *agent_name, b
612612
}
613613
rc = pcre2_match(re, (PCRE2_SPTR)ZSTR_VAL(agent_name), ZSTR_LEN(agent_name), 0, 0, match_data, php_pcre_mctx());
614614
php_pcre_free_match_data(match_data);
615-
if (PCRE2_ERROR_NOMATCH != rc) {
615+
if (rc >= 0) {
616616
/* If we've found a possible browser, we need to do a comparison of the
617617
number of characters changed in the user agent being checked versus
618618
the previous match found and the current match. */

0 commit comments

Comments
 (0)