]> granicus.if.org Git - php/commitdiff
Fixed Bug #69883 (Compilation failed on PCRE)
authorXinchen Hui <laruence@php.net>
Fri, 19 Jun 2015 12:33:14 +0000 (20:33 +0800)
committerXinchen Hui <laruence@php.net>
Fri, 19 Jun 2015 12:33:14 +0000 (20:33 +0800)
ext/pcre/php_pcre.c

index 2d75bc2f3e24bcd0dc26dc2ede8cc5390367c58f..11b74b45b3be084a61479ca436ea111005943ad3 100644 (file)
@@ -1082,7 +1082,11 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
        /* Calculate the size of the offsets array, and allocate memory for it. */
        num_subpats = pce->capture_count + 1;
        size_offsets = num_subpats * 3;
-       offsets = (int *)do_alloca_ex(size_offsets * sizeof(int), 32 * sizeof(int), use_heap);
+       if (size_offsets <= 32) {
+               offsets = (int *)do_alloca(size_offsets * sizeof(int), use_heap);
+       } else {
+               offsets = (int *)safe_emalloc(size_offsets, sizeof(int), 0);
+       }
 
        /*
         * Build a mapping from subpattern numbers to their names. We will
@@ -1279,7 +1283,11 @@ PHPAPI zend_string *php_pcre_replace_impl(pcre_cache_entry *pce, zend_string *su
                start_offset = offsets[1];
        }
 
-       free_alloca(offsets, use_heap);
+       if (size_offsets <= 32) {
+               free_alloca(offsets, use_heap);
+       } else {
+               efree(offsets);
+       }
        if (UNEXPECTED(subpat_names)) {
                efree(subpat_names);
        }