From 88378e43a45348e03bfd5dc937875af12d9a8ec8 Mon Sep 17 00:00:00 2001 From: ndossche Date: Mon, 20 Feb 2023 10:56:10 +0100 Subject: [PATCH] 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. --- ext/standard/browscap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/standard/browscap.c b/ext/standard/browscap.c index 2b6cd4e63f6cb..490acac2f99a5 100644 --- a/ext/standard/browscap.c +++ b/ext/standard/browscap.c @@ -612,7 +612,7 @@ static int browser_reg_compare(browscap_entry *entry, zend_string *agent_name, b } rc = pcre2_match(re, (PCRE2_SPTR)ZSTR_VAL(agent_name), ZSTR_LEN(agent_name), 0, 0, match_data, php_pcre_mctx()); php_pcre_free_match_data(match_data); - if (PCRE2_ERROR_NOMATCH != rc) { + if (rc >= 0) { /* If we've found a possible browser, we need to do a comparison of the number of characters changed in the user agent being checked versus the previous match found and the current match. */