summaryrefslogtreecommitdiff
path: root/ext/pcre/php_pcre.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@php.net>2015-06-19 20:33:14 +0800
committerXinchen Hui <laruence@php.net>2015-06-19 20:33:14 +0800
commit05c24d5dfa4719c4f15948ffd74f5266c60a4d67 (patch)
tree311e9b957ba68356ab8b7b7928751b5d98824b89 /ext/pcre/php_pcre.c
parent1e65b65dd683612925d99202c45ed8ed410edbde (diff)
downloadphp-git-05c24d5dfa4719c4f15948ffd74f5266c60a4d67.tar.gz
Fixed Bug #69883 (Compilation failed on PCRE)
Diffstat (limited to 'ext/pcre/php_pcre.c')
-rw-r--r--ext/pcre/php_pcre.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/ext/pcre/php_pcre.c b/ext/pcre/php_pcre.c
index 2d75bc2f3e..11b74b45b3 100644
--- a/ext/pcre/php_pcre.c
+++ b/ext/pcre/php_pcre.c
@@ -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);
}