Skip to content

Commit 9bf1240

Browse files
committed
array_map: Delay allocation of array_pos
1 parent 080cf10 commit 9bf1240

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

ext/standard/array.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6854,19 +6854,17 @@ PHP_FUNCTION(array_map)
68546854
} ZEND_HASH_FOREACH_END();
68556855
}
68566856
} else {
6857-
uint32_t *array_pos = (HashPosition *)ecalloc(n_arrays, sizeof(HashPosition));
6858-
68596857
for (i = 0; i < n_arrays; i++) {
68606858
if (Z_TYPE(arrays[i]) != IS_ARRAY) {
68616859
zend_argument_type_error(i + 2, "must be of type array, %s given", zend_zval_value_name(&arrays[i]));
6862-
efree(array_pos);
68636860
RETURN_THROWS();
68646861
}
68656862
if (zend_hash_num_elements(Z_ARRVAL(arrays[i])) > maxlen) {
68666863
maxlen = zend_hash_num_elements(Z_ARRVAL(arrays[i]));
68676864
}
68686865
}
68696866

6867+
uint32_t *array_pos = ecalloc(n_arrays, sizeof(HashPosition));
68706868
array_init_size(return_value, maxlen);
68716869

68726870
if (!ZEND_FCI_INITIALIZED(fci)) {

0 commit comments

Comments
 (0)