Skip to content

Commit 643810a

Browse files
committed
array_map: Rely on VM to clean up in case of an exception
This makes the code more compact, and less weird: the stub doesn't indicate that this function can return NULL.
1 parent b41587b commit 643810a

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

ext/standard/array.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6811,8 +6811,7 @@ PHP_FUNCTION(array_map)
68116811
ZEND_IGNORE_VALUE(ret);
68126812
if (UNEXPECTED(Z_ISUNDEF(result))) {
68136813
ZEND_HASH_FILL_FINISH();
6814-
zend_array_destroy(output);
6815-
RETURN_NULL();
6814+
RETURN_THROWS();
68166815
}
68176816
} else {
68186817
ZVAL_UNDEF(&result);
@@ -6835,8 +6834,7 @@ PHP_FUNCTION(array_map)
68356834
ZEND_ASSERT(ret == SUCCESS);
68366835
ZEND_IGNORE_VALUE(ret);
68376836
if (UNEXPECTED(Z_ISUNDEF(result))) {
6838-
zend_array_destroy(output);
6839-
RETURN_NULL();
6837+
RETURN_THROWS();
68406838
}
68416839
if (str_key) {
68426840
_zend_hash_append(output, str_key, &result);
@@ -6949,9 +6947,8 @@ PHP_FUNCTION(array_map)
69496947

69506948
if (Z_TYPE(result) == IS_UNDEF) {
69516949
efree(array_pos);
6952-
zend_array_destroy(Z_ARR_P(return_value));
69536950
efree(params);
6954-
RETURN_NULL();
6951+
RETURN_THROWS();
69556952
}
69566953

69576954
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &result);

0 commit comments

Comments
 (0)