From: Nuno Lopes Date: Tue, 14 Apr 2009 20:31:32 +0000 (+0000) Subject: MFH: fix bug #47662: support more than 127 named subpatterns X-Git-Tag: php-5.2.10RC1~217 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=925c892dc9ff2331802c627a4e5a01f0d078d421;p=php MFH: fix bug #47662: support more than 127 named subpatterns --- diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c index b412eb9f39..bcf9c425fa 100644 --- a/ext/pcre/php_pcre.c +++ b/ext/pcre/php_pcre.c @@ -209,7 +209,7 @@ static char **make_subpats_table(int num_subpats, pcre_cache_entry *pce TSRMLS_D } 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"); diff --git a/ext/pcre/tests/bug47662.phpt b/ext/pcre/tests/bug47662.phpt new file mode 100644 index 0000000000..d6056746cb --- /dev/null +++ b/ext/pcre/tests/bug47662.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #47662 (support more than 127 named subpatterns) +--FILE-- +))'; +} +$regex .= 'fo+bar@'; + +var_dump(preg_match($regex, 'foobar')); +echo "Done!\n"; + +?> +--EXPECT-- +int(1) +Done!