Skip to content

Commit cbad7bf

Browse files
committed
ext/pcre: simplify pattern info error handling
1 parent f46bc8e commit cbad7bf

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

ext/pcre/php_pcre.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -826,19 +826,8 @@ PHPAPI pcre_cache_entry* pcre_get_compiled_regex_cache_ex(zend_string *regex, bo
826826
new_entry.refcount = 0;
827827
new_entry.subpats_table = NULL;
828828

829-
rc = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &new_entry.capture_count);
830-
if (rc < 0) {
831-
if (key != regex) {
832-
zend_string_release_ex(key, 0);
833-
}
834-
pcre2_code_free(new_entry.re);
835-
php_error_docref(NULL, E_WARNING, "Internal pcre2_pattern_info() error %d", rc);
836-
pcre_handle_exec_error(PCRE2_ERROR_INTERNAL);
837-
return NULL;
838-
}
839-
840-
rc = pcre2_pattern_info(re, PCRE2_INFO_NAMECOUNT, &new_entry.name_count);
841-
if (rc < 0) {
829+
if ((rc = pcre2_pattern_info(re, PCRE2_INFO_CAPTURECOUNT, &new_entry.capture_count)) < 0 ||
830+
(rc = pcre2_pattern_info(re, PCRE2_INFO_NAMECOUNT, &new_entry.name_count)) < 0) {
842831
if (key != regex) {
843832
zend_string_release_ex(key, 0);
844833
}

0 commit comments

Comments
 (0)