@@ -420,7 +421,32 @@
size_offsets = num_subpats * 3;
offsets = (int *)safe_emalloc(size_offsets, sizeof(int), 0);
- /* Allocate match sets array and initialize the values */
+ /*
+ * Build a mapping from subpattern numbers to their names. We will always
+ * allocate the table, even though they may be no named subpatterns. This
+ * avoids somewhat more complicated logic in the inner loops.
+ */
+ subpat_names = (char **)safe_emalloc(num_subpats, sizeof(char *), 0);
+ memset(subpat_names, 0, sizeof(char *) * num_subpats);
+ {
+ int name_cnt, name_size, ni = 0;
+ char *name_table;
+ unsigned short name_idx;
+
+ pcre_fullinfo(re, extra, PCRE_INFO_NAMECOUNT, &name_cnt);
+ if (name_cnt > 0) {
+ pcre_fullinfo(re, extra, PCRE_INFO_NAMETABLE, &name_table);
+ pcre_fullinfo(re, extra, PCRE_INFO_NAMEENTRYSIZE, &name_size);
+
+ while (ni++ < name_cnt) {
+ name_idx = 0xff * name_table[0] + name_table[1];
+ subpat_names[name_idx] = name_table + 2;

I'm getting name_idx = 23078, sizeof(subpat_names) = 4 here.


backing out the patch solves the problem

(sorry I've no idea what the code causing the problem is - it's part of a huge app...)

Regards
Alan


+                               name_table += name_size;
+                       }
+               }
+       }
+
+       /* Allocate match sets array and initialize the values. */
        if (global && subpats_order == PREG_PATTERN_ORDER) {
                match_sets = (zval **)safe_emalloc(num_subpats, sizeof(zval *), 0);
                for (i=0; i<num_subpats; i++) {



-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to