Skip to content

Commit 60a0f10

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 9bf1240 commit 60a0f10

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
@@ -6819,8 +6819,7 @@ PHP_FUNCTION(array_map)
68196819
ZEND_IGNORE_VALUE(ret);
68206820
if (UNEXPECTED(Z_ISUNDEF(result))) {
68216821
ZEND_HASH_FILL_FINISH();
6822-
zend_array_destroy(output);
6823-
RETURN_NULL();
6822+
RETURN_THROWS();
68246823
}
68256824
} else {
68266825
ZVAL_UNDEF(&result);
@@ -6843,8 +6842,7 @@ PHP_FUNCTION(array_map)
68436842
ZEND_ASSERT(ret == SUCCESS);
68446843
ZEND_IGNORE_VALUE(ret);
68456844
if (UNEXPECTED(Z_ISUNDEF(result))) {
6846-
zend_array_destroy(output);
6847-
RETURN_NULL();
6845+
RETURN_THROWS();
68486846
}
68496847
if (str_key) {
68506848
_zend_hash_append(output, str_key, &result);
@@ -6957,9 +6955,8 @@ PHP_FUNCTION(array_map)
69576955

69586956
if (Z_TYPE(result) == IS_UNDEF) {
69596957
efree(array_pos);
6960-
zend_array_destroy(Z_ARR_P(return_value));
69616958
efree(params);
6962-
RETURN_NULL();
6959+
RETURN_THROWS();
69636960
}
69646961

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

0 commit comments

Comments
 (0)