}
while (ni++ < name_cnt) {
- name_idx = 0xff * name_table[0] + name_table[1];
+ name_idx = 0xff * (unsigned char)name_table[0] + (unsigned char)name_table[1];
subpat_names[name_idx] = name_table + 2;
if (is_numeric_string(subpat_names[name_idx], strlen(subpat_names[name_idx]), NULL, NULL, 0) > 0) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Numeric named subpatterns are not allowed");
--- /dev/null
+--TEST--
+Bug #47662 (support more than 127 named subpatterns)
+--FILE--
+<?php
+
+$regex = '@';
+for($bar=0; $bar<1027; $bar++) {
+ $regex .= '((?P<x'.$bar.'>))';
+}
+$regex .= 'fo+bar@';
+
+var_dump(preg_match($regex, 'foobar'));
+echo "Done!\n";
+
+?>
+--EXPECT--
+int(1)
+Done!