summaryrefslogtreecommitdiff
path: root/ext/standard/array.c
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2019-01-02 12:09:47 +0800
committerXinchen Hui <laruence@gmail.com>2019-01-02 12:09:47 +0800
commit8ebae84674c75c3483550fb6e9da49122d952c99 (patch)
treec96fa263b74f1d90de648b365d9054d3ebafb10d /ext/standard/array.c
parentb0cfa28d6d4e6f7855093b4fb66ccf3a2d07660e (diff)
downloadphp-git-8ebae84674c75c3483550fb6e9da49122d952c99.tar.gz
Fixed bug #77395 (segfault about array_multisort)
Diffstat (limited to 'ext/standard/array.c')
-rw-r--r--ext/standard/array.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ext/standard/array.c b/ext/standard/array.c
index dfff41b6aa..e810defcda 100644
--- a/ext/standard/array.c
+++ b/ext/standard/array.c
@@ -5555,7 +5555,7 @@ PHPAPI int php_multisort_compare(const void *a, const void *b) /* {{{ */
/* }}} */
#define MULTISORT_ABORT \
- efree(ARRAYG(multisort_func)); \
+ efree(func); \
efree(arrays); \
RETURN_FALSE;
@@ -5587,6 +5587,7 @@ PHP_FUNCTION(array_multisort)
int sort_order = PHP_SORT_ASC;
int sort_type = PHP_SORT_REGULAR;
int i, k, n;
+ compare_func_t *func;
ZEND_PARSE_PARAMETERS_START(1, -1)
Z_PARAM_VARIADIC('+', args, argc)
@@ -5597,7 +5598,7 @@ PHP_FUNCTION(array_multisort)
for (i = 0; i < MULTISORT_LAST; i++) {
parse_state[i] = 0;
}
- ARRAYG(multisort_func) = (compare_func_t*)ecalloc(argc, sizeof(compare_func_t));
+ func = ARRAYG(multisort_func) = (compare_func_t*)ecalloc(argc, sizeof(compare_func_t));
/* Here we go through the input arguments and parse them. Each one can
* be either an array or a sort flag which follows an array. If not
@@ -5681,7 +5682,7 @@ PHP_FUNCTION(array_multisort)
/* If all arrays are empty we don't need to do anything. */
if (array_size < 1) {
- efree(ARRAYG(multisort_func));
+ efree(func);
efree(arrays);
RETURN_TRUE;
}
@@ -5740,7 +5741,7 @@ PHP_FUNCTION(array_multisort)
efree(indirect[i]);
}
efree(indirect);
- efree(ARRAYG(multisort_func));
+ efree(func);
efree(arrays);
RETURN_TRUE;
}