Skip to content

Commit c349660

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 dbce033 commit c349660

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
@@ -6818,8 +6818,7 @@ PHP_FUNCTION(array_map)
68186818
ZEND_IGNORE_VALUE(ret);
68196819
if (UNEXPECTED(Z_ISUNDEF(result))) {
68206820
ZEND_HASH_FILL_FINISH();
6821-
zend_array_destroy(output);
6822-
RETURN_NULL();
6821+
RETURN_THROWS();
68236822
}
68246823
} else {
68256824
ZVAL_UNDEF(&result);
@@ -6842,8 +6841,7 @@ PHP_FUNCTION(array_map)
68426841
ZEND_ASSERT(ret == SUCCESS);
68436842
ZEND_IGNORE_VALUE(ret);
68446843
if (UNEXPECTED(Z_ISUNDEF(result))) {
6845-
zend_array_destroy(output);
6846-
RETURN_NULL();
6844+
RETURN_THROWS();
68476845
}
68486846
if (str_key) {
68496847
_zend_hash_append(output, str_key, &result);
@@ -6956,9 +6954,8 @@ PHP_FUNCTION(array_map)
69566954

69576955
if (Z_TYPE(result) == IS_UNDEF) {
69586956
efree(array_pos);
6959-
zend_array_destroy(Z_ARR_P(return_value));
69606957
efree(params);
6961-
RETURN_NULL();
6958+
RETURN_THROWS();
69626959
}
69636960

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

0 commit comments

Comments
 (0)